/* ==========================================================================
   MaqZAP — visual inspirado no iOS: vidro translúcido, cantos grandes,
   cores do sistema, tema claro/escuro e movimentos suaves.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, Roboto, Arial, sans-serif;

  /* cores do sistema (iOS) */
  --blue: #15803d;   --blue-soft: rgba(21, 128, 61, .13);
  --green: #34c759;  --green-soft: rgba(52, 199, 89, .16);
  --red: #ff3b30;    --red-soft: rgba(255, 59, 48, .12);
  --amber: #ff9500;  --amber-soft: rgba(255, 149, 0, .16);
  --purple: #af52de; --purple-soft: rgba(175, 82, 222, .14);
  --teal: #30b0c7;   --teal-soft: rgba(48, 176, 199, .15);

  --text: #1c1c1e;
  --muted: #6c6c72;
  --hairline: rgba(60, 60, 67, .16);
  --line: rgba(60, 60, 67, .12);

  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .86);
  --glass-edge: rgba(255, 255, 255, .85);
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(118, 118, 128, .10);
  --field: rgba(118, 118, 128, .12);
  --shadow: 0 10px 34px rgba(30, 41, 90, .10), 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-lift: 0 18px 44px rgba(30, 41, 90, .16), 0 2px 4px rgba(0, 0, 0, .06);
  --ring: 0 0 0 4px rgba(22, 163, 74, .22);

  --bubble-in: rgba(255, 255, 255, .92);
  --bubble-out: linear-gradient(180deg, #22c55e, #16a34a);
  --bubble-auto: rgba(175, 82, 222, .16);

  --wall:
    radial-gradient(1100px 650px at 6% -8%, rgba(22, 163, 74, .24), transparent 62%),
    radial-gradient(900px 600px at 96% 2%, rgba(175, 82, 222, .20), transparent 62%),
    radial-gradient(900px 700px at 62% 112%, rgba(48, 176, 199, .22), transparent 62%),
    linear-gradient(180deg, #f3f6fc, #e8eef9);

  --radius: 20px;
  --radius-sm: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: var(--font);
  color: var(--text);
}

/* Tema escuro: escolhido pelo usuário ou, se "automático", pelo sistema */
:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #16a34a;   --blue-soft: rgba(34, 197, 94, .20);
  --green: #30d158;  --green-soft: rgba(48, 209, 88, .18);
  --red: #ff453a;    --red-soft: rgba(255, 69, 58, .18);
  --amber: #ff9f0a;  --amber-soft: rgba(255, 159, 10, .20);
  --purple: #bf5af2; --purple-soft: rgba(191, 90, 242, .20);
  --teal: #40c8e0;   --teal-soft: rgba(64, 200, 224, .20);
  --text: #f5f5f7;
  --muted: #a1a1a8;
  --hairline: rgba(255, 255, 255, .14);
  --line: rgba(255, 255, 255, .10);
  --glass: rgba(34, 36, 48, .58);
  --glass-strong: rgba(34, 36, 48, .88);
  --glass-edge: rgba(255, 255, 255, .10);
  --surface: rgba(255, 255, 255, .07);
  --surface-2: rgba(255, 255, 255, .09);
  --field: rgba(255, 255, 255, .10);
  --shadow: 0 12px 38px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lift: 0 22px 54px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .35);
  --ring: 0 0 0 4px rgba(34, 197, 94, .38);
  --bubble-in: rgba(255, 255, 255, .11);
  --bubble-out: linear-gradient(180deg, #34d399, #16a34a);
  --bubble-auto: rgba(191, 90, 242, .24);
  --wall:
    radial-gradient(1100px 650px at 6% -8%, rgba(34, 197, 94, .30), transparent 62%),
    radial-gradient(900px 600px at 96% 2%, rgba(191, 90, 242, .26), transparent 62%),
    radial-gradient(900px 700px at 62% 112%, rgba(64, 200, 224, .20), transparent 62%),
    linear-gradient(180deg, #0c0e16, #07080d);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --blue: #16a34a;   --blue-soft: rgba(34, 197, 94, .20);
    --green: #30d158;  --green-soft: rgba(48, 209, 88, .18);
    --red: #ff453a;    --red-soft: rgba(255, 69, 58, .18);
    --amber: #ff9f0a;  --amber-soft: rgba(255, 159, 10, .20);
    --purple: #bf5af2; --purple-soft: rgba(191, 90, 242, .20);
    --teal: #40c8e0;   --teal-soft: rgba(64, 200, 224, .20);
    --text: #f5f5f7;
    --muted: #a1a1a8;
    --hairline: rgba(255, 255, 255, .14);
    --line: rgba(255, 255, 255, .10);
    --glass: rgba(34, 36, 48, .58);
    --glass-strong: rgba(34, 36, 48, .88);
    --glass-edge: rgba(255, 255, 255, .10);
    --surface: rgba(255, 255, 255, .07);
    --surface-2: rgba(255, 255, 255, .09);
    --field: rgba(255, 255, 255, .10);
    --shadow: 0 12px 38px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lift: 0 22px 54px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .35);
    --ring: 0 0 0 4px rgba(34, 197, 94, .38);
    --bubble-in: rgba(255, 255, 255, .11);
    --bubble-out: linear-gradient(180deg, #34d399, #16a34a);
    --bubble-auto: rgba(191, 90, 242, .24);
    --wall:
      radial-gradient(1100px 650px at 6% -8%, rgba(34, 197, 94, .30), transparent 62%),
      radial-gradient(900px 600px at 96% 2%, rgba(191, 90, 242, .26), transparent 62%),
      radial-gradient(900px 700px at 62% 112%, rgba(64, 200, 224, .20), transparent 62%),
      linear-gradient(180deg, #0c0e16, #07080d);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--wall) fixed; min-height: 100vh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.22; letter-spacing: -.012em; }
h2 { font-size: 1.08rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
small, .muted { color: var(--muted); }
::selection { background: var(--blue-soft); }
.icon { flex-shrink: 0; }

/* Vidro: base comum das superfícies translúcidas */
.card, .kpi, .sidebar, .topbar, .alert, .toast, .kanban-col, .login-card, .filters-card, .segmented, .window-banner, .name-prompt {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-edge);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card, .kpi, .sidebar, .topbar, .alert, .toast, .kanban-col, .login-card, .filters-card, .segmented { background: var(--glass-strong); }
}

/* Estrutura */
.shell { display: flex; min-height: 100vh; padding: 14px; gap: 16px; }
.sidebar {
  width: 252px; border-radius: 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding: 1rem .75rem .85rem;
  position: sticky; top: 14px; height: calc(100vh - 28px); overflow-y: auto; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; font-size: .95rem; line-height: 1.15; padding: .15rem .6rem .8rem; letter-spacing: -.01em; }
.brand-dark { padding: 0 0 1.25rem; }
.brand-mark {
  background: linear-gradient(145deg, #4ade80, #15803d); color: #fff; border-radius: 12px; width: 38px; height: 38px;
  display: grid; place-items: center; font-weight: 800; flex-shrink: 0; box-shadow: 0 6px 16px rgba(22, 163, 74, .35), inset 0 1px 0 rgba(255,255,255,.35);
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: .7rem; color: var(--text); padding: .45rem .75rem; border-radius: 13px;
  font-size: .93rem; font-weight: 500; transition: background .18s var(--ease), transform .18s var(--ease), color .18s;
}
.sidebar nav a .icon { color: var(--muted); transition: color .18s; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a:active { transform: scale(.98); }
.sidebar nav a.active { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(22, 163, 74, .32); }
.sidebar nav a.active .icon { color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .55rem; padding: .9rem .25rem 0; border-top: 1px solid var(--line); }
.sidebar-foot .who { display: flex; flex-direction: column; padding: 0 .35rem; }
.sidebar-foot .who span { font-size: .8rem; color: var(--muted); }
.sidebar-foot .btn-ghost { width: 100%; }
.main { flex: 1; min-width: 0; padding: .25rem .5rem 2.5rem 0; animation: rise .5s var(--ease) both; }
.topbar {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; padding: .7rem 1.1rem; border-radius: 22px;
  box-shadow: var(--shadow); position: sticky; top: 14px; z-index: 5;
}
.topbar h1 { font-size: 1.55rem; margin: 0; font-weight: 750; letter-spacing: -.025em; }
.menu-toggle { display: none; background: var(--surface-2); border: 0; border-radius: 12px; padding: .35rem .6rem; cursor: pointer; color: var(--text); }
.theme-switch { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.theme-switch button { flex: 1; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); padding: .35rem; border-radius: 9px; cursor: pointer; transition: background .18s, color .18s; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--glass-strong); color: var(--blue); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Componentes */
.card { border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid > .card { margin-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.kpi { border-radius: 20px; box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .1rem; position: relative; overflow: hidden; transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.kpi > span { color: var(--muted); font-size: .8rem; }
.kpi strong { display: block; font-size: 1.65rem; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi strong small { font-size: .72rem; font-weight: 500; letter-spacing: 0; }
.kpi small { font-size: .78rem; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.kpi-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.tint-blue { background: var(--blue-soft); color: var(--blue); }
.tint-green { background: var(--green-soft); color: var(--green); }
.tint-purple { background: var(--purple-soft); color: var(--purple); }
.tint-amber { background: var(--amber-soft); color: var(--amber); }
.tint-teal { background: var(--teal-soft); color: var(--teal); }
.tint-red { background: var(--red-soft); color: var(--red); }
.kpi .spark { position: absolute; right: 12px; top: 3.35rem; width: 64px; height: 26px; opacity: .95; }
.spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.delta { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.delta.good { background: var(--green-soft); color: var(--green); }
.delta.bad { background: var(--red-soft); color: var(--red); }
.delta.flat { background: var(--surface-2); color: var(--muted); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(52, 199, 89, .6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(52, 199, 89, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); } }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 0; background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: .5rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), background .18s, box-shadow .18s, filter .18s;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(22, 163, 74, .32); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--hairline); }
.btn-link { background: transparent; color: var(--blue); padding: .1rem .3rem; font-weight: 500; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Avisos e etiquetas */
.alert { padding: .75rem 1rem; border-radius: 16px; margin-bottom: 1rem; box-shadow: var(--shadow); }
.alert-success { background: var(--green-soft); border-color: transparent; color: var(--green); }
.alert-error { background: var(--red-soft); border-color: transparent; color: var(--red); }
.alert-info { background: var(--blue-soft); border-color: transparent; color: var(--text); }
:root[data-theme="dark"] .alert-info { color: var(--text); }
.pill { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.tag { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 650; color: #fff; }

/* Formulários */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 550; font-size: .85rem; color: var(--text); }
input, select, textarea {
  font: inherit; padding: .55rem .75rem; border: 1px solid transparent; border-radius: 12px; background: var(--field); color: var(--text); min-width: 0;
  transition: box-shadow .18s, border-color .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); background: var(--surface); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); transform: scale(1.1); }
input[type=range] { padding: 0; accent-color: var(--blue); background: transparent; }
.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 450; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .85rem; align-items: end; }
.form-row { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.form-actions { display: flex; gap: .5rem; margin-top: .85rem; flex-wrap: wrap; }
.days { display: flex; gap: .4rem; flex-wrap: wrap; margin: .35rem 0; }
.days label { flex-direction: row; gap: .3rem; font-weight: 450; background: var(--surface-2); padding: .25rem .65rem; border-radius: 999px; }
.inline { display: inline; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: transparent; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* Caixa de entrada */
.inbox { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-item { display: flex; gap: .75rem; padding: .75rem .6rem; border-bottom: 1px solid var(--line); color: inherit; border-radius: 14px; transition: background .15s; }
.conv-item:hover { background: var(--surface-2); text-decoration: none; }
.conv-avatar, .avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(145deg, var(--blue-soft), var(--purple-soft)); color: var(--blue); display: grid; place-items: center; font-weight: 750; flex-shrink: 0; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: .5rem; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Atendimento */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 1rem; align-items: start; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 440px; padding: 0; overflow: hidden; }
.chat-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .5rem; align-items: center; flex-wrap: wrap; }
.messages { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; background: var(--surface-2); display: flex; flex-direction: column; gap: .35rem; }
.msg { max-width: 72%; padding: .5rem .8rem .35rem; border-radius: 20px; overflow-wrap: anywhere; }
.msg.enter { animation: pop .25s var(--ease) both; } /* só mensagens que acabaram de chegar (nunca as que a atualização recria) */
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
/* Mensagem do cliente chegando: desliza da esquerda com leve "mola" e um brilho verde que se apaga */
.msg-in.enter { transform-origin: left bottom; animation: msg-in-pop .55s cubic-bezier(.2, .9, .25, 1.25) both; }
.msg-out.enter { transform-origin: right bottom; animation: msg-out-pop .4s cubic-bezier(.2, .9, .25, 1.15) both; }
.msg-in.arrive { animation: msg-in-pop .55s cubic-bezier(.2, .9, .25, 1.25) both, msg-glow 2.1s ease-out both; }
@keyframes msg-in-pop { 0% { opacity: 0; transform: translateX(-26px) scale(.86); } 60% { opacity: 1; transform: translateX(3px) scale(1.02); } 100% { opacity: 1; transform: none; } }
@keyframes msg-out-pop { 0% { opacity: 0; transform: translateX(22px) scale(.9); } 100% { opacity: 1; transform: none; } }
@keyframes msg-glow { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55), 0 0 22px 4px rgba(37, 211, 102, .45); } 100% { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0), 0 0 0 0 rgba(37, 211, 102, 0); } }
.msg-body { white-space: pre-wrap; }
.msg-in { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.msg-out { align-self: flex-end; background: var(--bubble-out); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 14px rgba(22, 163, 74, .25); }
.msg-out .msg-meta { color: rgba(255, 255, 255, .75); }
.msg-out a { color: #fff; text-decoration: underline; }
.msg-meta { display: flex; gap: .4rem; justify-content: flex-end; font-size: .7rem; color: var(--muted); margin-top: .15rem; align-items: center; }
.msg-failed, .msg-out.msg-failed { background: var(--red-soft); color: var(--text); box-shadow: none; }
.msg-out.msg-failed .msg-meta { color: var(--muted); }
.msg-status-failed { color: var(--red); font-weight: 650; }
.composer { display: flex; gap: .55rem; padding: .8rem; border-top: 1px solid var(--line); background: var(--glass); align-items: flex-end; }
.composer textarea { flex: 1; min-height: 46px; max-height: 160px; border-radius: 18px; }
.composer .btn-primary { border-radius: 999px; padding: .6rem 1.2rem; }
.side-panel .card { margin-bottom: .85rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .85rem; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tag-choices { display: flex; flex-wrap: wrap; gap: .4rem .8rem; }
.note { border-left: 3px solid var(--blue); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: .35rem .7rem; margin-bottom: .5rem; font-size: .85rem; white-space: pre-wrap; }
.sale-item { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-bottom: .65rem; padding-bottom: .65rem; border-bottom: 1px dashed var(--hairline); }
details summary { cursor: pointer; font-weight: 650; color: var(--text); list-style-position: inside; }
details[open] summary { margin-bottom: .65rem; }

.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #86efac, var(--blue)); border-radius: 999px; transition: width .8s var(--ease); }
.qr-box { display: grid; place-items: center; min-height: 280px; background: #fff; border: 1px dashed var(--hairline); border-radius: var(--radius); }
.qr-box img { width: 264px; height: 264px; image-rendering: pixelated; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.big-status { font-size: 3rem; font-weight: 750; letter-spacing: -.03em; }
.sortable li { list-style: none; display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: 14px; margin-bottom: .4rem; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.sortable { padding: 0; margin: 0; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace; font-size: .82rem; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { padding: 2.1rem; border-radius: 28px; width: min(400px, 92vw); display: flex; flex-direction: column; gap: 1rem; box-shadow: var(--shadow-lift); animation: rise .6s var(--ease) both; }

/* Responsivo */
@media (max-width: 1100px) {
  .chat-layout, .inbox { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .grid-main, .grid-3 { grid-template-columns: 1fr !important; }
}
@media (max-width: 800px) {
  .shell { padding: 10px; gap: 0; }
  .sidebar { position: fixed; left: -280px; top: 10px; height: calc(100vh - 20px); z-index: 30; transition: left .3s var(--ease); background: var(--glass-strong); }
  .sidebar.open { left: 10px; }
  .menu-toggle { display: inline-block; }
  .main { padding: 0 0 2rem; }
  .topbar { top: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { flex-direction: column; align-items: flex-start; }
}

/* Mensagens não respondidas e alertas */
.conv-item.conv-unanswered { background: var(--amber-soft); border-left: 4px solid var(--amber); padding-left: calc(.6rem - 4px); }
.conv-unanswered .conv-preview { color: var(--text); font-weight: 650; }
.conv-unanswered .conv-avatar { background: var(--amber); color: #fff; }
.pill-unanswered { background: var(--amber); color: #fff; }
.waiting { color: var(--amber); font-weight: 650; }
.msg.msg-unanswered { background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber); }
.nav-badge { display: inline-block; min-width: 1.4rem; padding: 0 .45rem; margin-left: auto; border-radius: 999px; background: var(--red); color: #fff; font-size: .74rem; font-weight: 700; text-align: center; }
.sound-hint { cursor: pointer; }

/* Brilho pulsante: âmbar = aguardando resposta; verde = mensagem que o vendedor ainda não abriu */
/* Destaque calmo (sem piscar): fundo suave + faixa lateral; só a faixa de "não aberta" respira devagar. */
@keyframes bar-breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.conv-item.conv-unanswered { margin: 6px 2px; }
.conv-item.conv-unseen { border-left-color: var(--green); background: var(--green-soft); }
.conv-unseen .conv-avatar { background: var(--green); color: #fff; }
.pill-new { background: var(--green); color: #fff; letter-spacing: .04em; }

/* Conversa que acabou de chegar/receber mensagem na lista: entra deslizando e emite um brilho; contadores dão um "salto" */
.conv-arrive > td { animation: row-flash 2.4s ease-out both; }
.conv-arrive .conv-avatar, .conv-arrive .pill-new, .conv-arrive .pill-unanswered { animation: bump .7s cubic-bezier(.2, .9, .25, 1.4) both; }
@keyframes row-flash { 0% { background: rgba(37, 211, 102, .38); transform: translateY(-8px); opacity: .2; } 25% { transform: none; opacity: 1; } 100% { background: transparent; } }
.bump { animation: bump .7s cubic-bezier(.2, .9, .25, 1.4); display: inline-block; }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.38); } 70% { transform: scale(.94); } 100% { transform: scale(1); } }
.kpi strong.bump { transform-origin: left center; }

/* Aviso flutuante de mensagem nova (estilo notificação do iPhone) */
.toast-stack { position: fixed; right: 18px; top: 18px; bottom: auto; z-index: 50; display: flex; flex-direction: column; gap: .6rem; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: .75rem; align-items: center; border-radius: 22px; padding: .75rem .95rem; box-shadow: var(--shadow-lift); cursor: pointer; animation: toast-in .45s var(--ease); color: var(--text); }
.toast:hover { text-decoration: none; transform: scale(1.01); }
.toast-icon { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, #5ee07f, #25d366); color: #fff; display: grid; place-items: center; font-size: 1.1rem; flex-shrink: 0; }
.toast strong { display: block; }
.toast span { display: block; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
@keyframes toast-in { from { transform: translateY(-24px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Painel de som no menu lateral */
.sound-settings { background: var(--surface-2); border-radius: 14px; padding: .45rem .7rem; }
.sound-settings summary { font-weight: 650; font-size: .85rem; cursor: pointer; }
.sound-settings[open] { display: flex; flex-direction: column; gap: .55rem; padding-bottom: .7rem; }
.sound-settings label { font-size: .8rem; }
.sound-settings select, .sound-settings input[type=range] { width: 100%; }
.sound-settings .btn { width: 100%; }

/* Nome do cliente no cabeçalho do chat */
.contact-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.icon-btn { padding: .1rem .4rem; background: transparent; }
.rename-form { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rename-form input { width: 14rem; max-width: 100%; padding: .35rem .6rem; }
.name-prompt { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .65rem 1.1rem; background: var(--blue-soft); border-width: 0 0 1px; }
.name-prompt input { flex: 1 1 12rem; max-width: 20rem; padding: .4rem .65rem; }

/* Respostas rápidas e mensagens automáticas */
.quick-replies { display: flex; gap: .4rem; flex-wrap: wrap; padding: .6rem .8rem 0; border-top: 1px solid var(--line); background: var(--glass); }
.quick-reply { background: var(--surface-2); }
.quick-reply:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.msg.msg-auto { background: var(--bubble-auto); color: var(--text); box-shadow: none; }
.msg-out.msg-auto .msg-meta { color: var(--muted); }
.qr-preview { white-space: pre-wrap; font-size: .85rem; max-width: 46rem; }

/* Painel do vendedor */
.plan { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.plan-step { display: flex; gap: .8rem; align-items: flex-start; border-radius: 18px; padding: .9rem 1rem; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.plan-step p { margin: .25rem 0; }
.plan-alert { background: var(--amber-soft); box-shadow: inset 0 0 0 1px rgba(255, 149, 0, .35); }
.plan-todo { background: var(--surface); }
.plan-done { background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(52, 199, 89, .3); }
.step-ok, .step-todo { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; color: #fff; }
.step-ok { background: var(--green); }
.step-todo { background: var(--amber); }
.late { color: var(--red); font-weight: 650; }
table.week tr.today td { background: var(--blue-soft); font-weight: 650; }
table.week tfoot th { background: var(--surface-2); color: var(--text); font-size: .85rem; text-transform: none; letter-spacing: 0; }
.up { color: var(--green); font-weight: 700; }
.down { color: var(--red); font-weight: 700; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.tab { padding: .4rem .9rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .86rem; font-weight: 550; transition: background .18s, transform .15s var(--ease); }
.tab.active { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(22, 163, 74, .3); }
.tab:hover { text-decoration: none; filter: brightness(1.06); }
.tab:active { transform: scale(.96); }
.techniques details { background: var(--surface); border-radius: 16px; padding: .7rem 1rem; margin-bottom: .55rem; box-shadow: inset 0 0 0 1px var(--line); }
.techniques ol, .techniques ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.techniques li { margin-bottom: .35rem; }
.quick-replies-inline { border-top: 0; padding: 0 0 .75rem; background: transparent; }

/* Atendimentos finalizados */
.result-tabs { margin-bottom: 1rem; }
.result-tabs .tab { display: inline-flex; align-items: center; gap: .4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* Tabela de atendimentos */
.kpi-warn strong { color: var(--amber); }
.kpi-new strong { color: var(--green); }
.inbox-table tr.row-link { cursor: pointer; }
.inbox-table td.last-msg { max-width: 28rem; }
.inbox-table .conv-preview { display: inline-block; max-width: 28rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: var(--text); }
.inbox-table tr.conv-unanswered td { background: rgba(255, 149, 0, .09); }
.inbox-table tr.conv-unanswered td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.inbox-table tr.conv-unseen td { background: rgba(52, 199, 89, .12); }
.inbox-table tr.conv-unseen td:first-child { box-shadow: inset 4px 0 0 var(--green); }
.inbox-table tr.conv-unseen td:first-child strong::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: .45rem; border-radius: 50%; background: var(--green); animation: bar-breathe 2.6s ease-in-out infinite; }
.inbox-table tr.conv-unanswered .conv-preview, .inbox-table tr.conv-unseen .conv-preview { font-weight: 650; }

/* Disparos: quadro estilo Trello */
.kanban { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 270px; border-radius: 22px; display: flex; flex-direction: column; max-height: 75vh; transition: background .15s, box-shadow .15s; box-shadow: var(--shadow); }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem .85rem; border-top: 4px solid var(--muted); border-radius: 22px 22px 0 0; font-size: .85rem; }
.kanban-count { background: var(--surface-2); border-radius: 999px; padding: 0 .55rem; font-size: .75rem; font-weight: 700; color: var(--muted); }
.kanban-cards { padding: 0 .6rem .7rem; overflow-y: auto; display: flex; flex-direction: column; gap: .55rem; min-height: 60px; }
.kanban-card { background: var(--surface); border-radius: 16px; padding: .65rem .75rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .10); display: flex; flex-direction: column; gap: .25rem; font-size: .83rem; transition: transform .2s var(--ease), box-shadow .2s; }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.dragging { opacity: .45; }
.kanban-card-title { display: flex; justify-content: space-between; gap: .4rem; align-items: baseline; }
.kanban-preview { background: var(--surface-2); border-radius: 10px; padding: .3rem .5rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kanban-note { color: var(--muted); font-style: italic; }
.kanban-link { font-size: .78rem; font-weight: 650; }
.kanban-col.drop-ok { box-shadow: inset 0 0 0 2px var(--blue-soft), var(--shadow); }
.kanban-col.drop-hover { box-shadow: inset 0 0 0 2px var(--blue), var(--shadow); }
.kanban-help { margin: 0 0 .5rem; }
.step-row { background: var(--surface); border-radius: 16px; padding: .7rem .85rem; margin-bottom: .7rem; display: flex; flex-direction: column; gap: .45rem; box-shadow: inset 0 0 0 1px var(--line); }
.step-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.inline-label { flex-direction: row; align-items: center; gap: .4rem; font-weight: 450; }
.inline-label input { width: 4.5rem; }
.step-list { padding-left: 1.2rem; }
.step-list li { margin-bottom: .6rem; }

/* Canais e janela de resposta da Meta */
.channel { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.channel-whatsapp { background: var(--green-soft); color: var(--green); }
.channel-instagram { background: var(--purple-soft); color: var(--purple); }
.channel-messenger { background: var(--blue-soft); color: var(--blue); }
.window-banner { padding: .55rem 1.1rem; background: var(--blue-soft); border-width: 0 0 1px; font-size: .85rem; }
.window-banner.window-warn { background: var(--amber-soft); }
.window-banner.window-closed { background: var(--red-soft); }

.msg-error { margin-top: .25rem; font-size: .75rem; color: var(--red); }
.form-row label.wide { flex: 1 1 100%; }
.form-grid label.wide { grid-column: 1 / -1; }

/* Cotações */
.quote { background: var(--surface); border-radius: 16px; padding: .7rem .85rem; margin-bottom: .65rem; box-shadow: inset 0 0 0 1px var(--line); }
.quote-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.quote-total { margin-left: auto; font-size: 1.05rem; }
.quote-items { margin: .4rem 0; padding-left: 1.1rem; }
.sale-item .specs { grid-column: 1 / -1; }

/* Persona: observações em cards */
.obs-title { margin: 1rem 0 .4rem; font-size: .95rem; }
.obs { background: var(--surface); border-radius: 16px; padding: .6rem .8rem; margin: .5rem 0; box-shadow: inset 0 0 0 1px var(--line); }
.obs p { margin: 0 0 .3rem; overflow-wrap: anywhere; }
.obs small { display: block; }
.obs.deleted { background: var(--surface-2); }
.obs.deleted p { text-decoration: line-through; opacity: .6; }
.obs .obs-deleted { color: var(--red); }
.obs-form textarea { width: 100%; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .25rem .25rem 1rem; flex-wrap: wrap; }
.hero p { margin: 0; }
.eyebrow { font-size: .74rem; font-weight: 700; letter-spacing: .08em; color: var(--blue); }
.hero-title { font-size: 1.9rem; font-weight: 780; letter-spacing: -.03em; margin: .1rem 0 .15rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 13px; gap: 2px; }
.segmented a { padding: .35rem .95rem; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .86rem; transition: background .2s var(--ease), color .2s; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.on { background: var(--glass-strong); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .14); }
.filters-card { border-radius: 18px; padding: .65rem 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.filters-card summary { font-size: .88rem; color: var(--muted); }
.filters-card[open] summary { margin-bottom: .8rem; }
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); margin-bottom: 1rem; }
.grid-3 { margin-bottom: 1rem; }

svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
svg.chart .axis { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
svg.chart .line { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
svg.chart .dot-end { stroke: var(--glass-strong); stroke-width: 2; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: var(--surface-2); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i, .legend-list i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.donut-wrap { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
svg.donut { width: 138px; height: 138px; flex-shrink: 0; transform: rotate(0deg); }
.donut-track { fill: none; stroke: var(--surface-2); stroke-width: 4.2; }
.donut-seg { fill: none; stroke-width: 4.2; stroke-linecap: round; transition: stroke-width .2s; }
.donut-seg:hover { stroke-width: 5; }
.donut-total { fill: var(--text); font-size: 6.4px; font-weight: 750; font-family: var(--font); }
.donut-sub { fill: var(--muted); font-size: 2.6px; font-family: var(--font); }
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; flex: 1; min-width: 130px; font-size: .86rem; }
.legend-list li { display: flex; align-items: center; gap: .5rem; }
.legend-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list strong { font-variant-numeric: tabular-nums; }

/* Central de avisos: estilo notificação do iPhone */
.notices { display: flex; flex-direction: column; gap: .55rem; }
.notices .card-head { margin-bottom: .25rem; }
.notice { display: flex; gap: .75rem; align-items: center; padding: .65rem .8rem; border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); transition: transform .2s var(--ease), box-shadow .2s; animation: rise .5s var(--ease) both; }
.notice:nth-child(2) { animation-delay: .04s; } .notice:nth-child(3) { animation-delay: .08s; } .notice:nth-child(4) { animation-delay: .12s; }
.notice:nth-child(5) { animation-delay: .16s; } .notice:nth-child(6) { animation-delay: .2s; } .notice:nth-child(7) { animation-delay: .24s; }
a.notice:hover { text-decoration: none; transform: translateX(3px); box-shadow: inset 0 0 0 1px var(--hairline), var(--shadow); }
.notice-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--blue-soft); color: var(--blue); }
.notice-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.notice-body small { color: var(--muted); }
.notice-critical { box-shadow: inset 0 0 0 1px rgba(255, 59, 48, .45); background: var(--red-soft); }
.notice-critical .notice-ico { background: var(--red); color: #fff; }
.notice-warn .notice-ico { background: var(--amber-soft); color: var(--amber); }
.notice-ok .notice-ico { background: var(--green-soft); color: var(--green); }

.leaders { display: flex; flex-direction: column; gap: .7rem; }
.leader { display: flex; align-items: center; gap: .9rem; padding: .65rem .8rem; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); flex-wrap: wrap; }
.leader-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: .35rem; }
.leader-top { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.leader-stats { display: flex; gap: 1.2rem; }
.leader-stats span { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.leader-stats small { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }

/* Quem é o cliente: novo, antigo ou de lista de disparos */
.context-banner { display: flex; gap: .75rem; align-items: center; padding: .65rem 1.1rem; border-bottom: 1px solid var(--line); }
.context-banner > div { display: flex; flex-direction: column; line-height: 1.35; }
.context-banner small { color: var(--muted); }
.context-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.context-new { background: var(--green-soft); } .context-new .context-ico { background: var(--green); color: #fff; }
.context-returning { background: var(--blue-soft); } .context-returning .context-ico { background: var(--blue); color: #fff; }
.context-campaign { background: var(--purple-soft); } .context-campaign .context-ico { background: var(--purple); color: #fff; }
.context-stale { background: var(--amber-soft); } .context-stale .context-ico { background: var(--amber); color: #fff; }

/* Mídias nas mensagens: imagem, vídeo, áudio e arquivo */
.msg-media { display: block; margin: .1rem 0 .3rem; max-width: 100%; }
.msg-img { display: block; max-width: min(280px, 100%); max-height: 340px; border-radius: 14px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); }
.msg-video { width: min(320px, 100%); max-height: 360px; border-radius: 14px; background: #000; }
.msg-audio { width: min(270px, 100%); height: 40px; }
.msg-file { padding: .5rem .75rem; border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.msg-out .msg-file { background: rgba(255, 255, 255, .22); color: #fff; }
.attach-chip { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem 1rem; background: var(--blue-soft); border-top: 1px solid var(--line); font-size: .85rem; }
.icon-circle { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 1.15rem; cursor: pointer; flex-shrink: 0; transition: transform .15s var(--ease), background .18s; }
.icon-circle:hover { background: var(--blue-soft); }
.icon-circle:active { transform: scale(.92); }
.composer .rec-bar { display: flex; align-items: center; gap: .6rem; flex: 1; padding: .35rem .5rem; }
.composer.recording > :not(.rec-bar) { display: none; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse-red 1.2s infinite; }
@keyframes pulse-red { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }

/* Listas suspensas: o popup do sistema não herda fundo translúcido; cores sólidas garantem texto legível nos dois temas. */
select option, select optgroup { background-color: #ffffff; color: #1c1c1e; }
:root[data-theme="dark"] select option, :root[data-theme="dark"] select optgroup { background-color: #2c2c2e; color: #f5f5f7; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) select option, :root:not([data-theme="light"]) select optgroup { background-color: #2c2c2e; color: #f5f5f7; }
}

/* Botão de finalizar atendimento, em destaque no topo da conversa */
.btn-finish {
  display: inline-flex; align-items: center; gap: .4rem; margin-left: .5rem; padding: .6rem 1.2rem; border-radius: 999px;
  background: var(--green); color: #fff; font-weight: 750; font-size: .95rem; text-decoration: none; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(52, 199, 89, .45); animation: finish-pulse 2.2s ease-in-out infinite;
}
.btn-finish:hover { filter: brightness(1.08); text-decoration: none; transform: translateY(-1px); }
@keyframes finish-pulse { 0%, 100% { box-shadow: 0 4px 14px rgba(52, 199, 89, .45); } 50% { box-shadow: 0 4px 22px rgba(52, 199, 89, .85); } }
#encerrar.flash { animation: finish-flash 1.6s ease; }
@keyframes finish-flash { 0%, 60% { box-shadow: 0 0 0 3px var(--green); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .btn-finish, #encerrar.flash { animation: none; } }

/* Painel de encerramento no topo da conversa */
.finish-panel { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); background: var(--green-soft); display: flex; flex-direction: column; gap: .7rem; animation: finish-open .22s var(--ease); }
.finish-panel[hidden] { display: none; }
@keyframes finish-open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.finish-title { font-weight: 750; font-size: 1rem; }
.finish-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.finish-chip { position: relative; display: inline-flex; flex-direction: row; cursor: pointer; font-weight: 650; }
.finish-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.finish-chip span { padding: .55rem 1rem; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--chip, var(--line)); transition: transform .12s, background .15s, color .15s; }
.finish-chip:hover span { transform: translateY(-1px); }
.finish-chip input:checked + span { background: var(--chip, var(--green)); color: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.finish-chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.finish-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .6rem .9rem; }
.finish-spacer { flex: 1; }
.finish-more { flex-basis: 100%; order: 5; }
.finish-more[open] { background: var(--surface); border-radius: 14px; padding: .5rem .8rem; }
.btn-finish-go { background: var(--green); color: #fff; font-weight: 750; padding: .6rem 1.3rem; box-shadow: 0 4px 14px rgba(52, 199, 89, .45); }
.btn-finish-go:hover { filter: brightness(1.08); }

/* Chave Disponível / Indisponível (lista de vendedores) */
.avail-toggle { display: inline-flex; align-items: center; gap: .5rem; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .82rem; padding: .25rem .8rem .25rem .3rem; border-radius: 999px; color: #fff; transition: filter .15s; }
.avail-toggle:hover { filter: brightness(1.1); }
.avail-toggle.is-on { background: var(--green); }
.avail-toggle.is-off { background: var(--red); }
.avail-knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.avail-toggle.is-off .avail-knob { order: 0; }

/* Mensagem de cliente não respondida / não aberta: o item brilha na tela do vendedor */
@keyframes glow-amber { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 149, 0, 0), inset 0 0 0 0 rgba(255, 149, 0, 0); } 50% { box-shadow: 0 0 22px 4px rgba(255, 149, 0, .75), inset 0 0 0 2px rgba(255, 149, 0, .9); } }
@keyframes glow-green { 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0), inset 0 0 0 0 rgba(52, 199, 89, 0); } 50% { box-shadow: 0 0 24px 5px rgba(52, 199, 89, .85), inset 0 0 0 2px rgba(52, 199, 89, 1); } }
@keyframes glow-cell-amber { 0%, 100% { background: rgba(255, 149, 0, .09); } 50% { background: rgba(255, 149, 0, .38); } }
@keyframes glow-cell-green { 0%, 100% { background: rgba(52, 199, 89, .12); } 50% { background: rgba(52, 199, 89, .45); } }
.conv-item.conv-unanswered { animation: glow-amber 1.6s ease-in-out infinite; }
.conv-item.conv-unseen { animation: glow-green 1.3s ease-in-out infinite; }
.inbox-table tr.conv-unanswered td { animation: glow-cell-amber 1.6s ease-in-out infinite; }
.inbox-table tr.conv-unseen td { animation: glow-cell-green 1.3s ease-in-out infinite; }
.pill-new { animation: glow-green 1.3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .conv-item.conv-unanswered, .conv-item.conv-unseen, .inbox-table tr.conv-unanswered td, .inbox-table tr.conv-unseen td, .pill-new { animation: none; }
}

/* Valor da venda na barra de encerramento */
.finish-sale { display: flex; flex-direction: row; align-items: center; gap: .7rem; padding: .6rem .9rem; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--green); font-weight: 700; }
.finish-sale[hidden] { display: none; }
.finish-sale input { max-width: 14rem; font-size: 1.1rem; font-weight: 700; }

/* Nota da venda (encerramento) e histórico de compras do cliente */
.finish-sale-box { display: flex; flex-wrap: wrap; gap: .6rem; }
.finish-sale-box[hidden] { display: none; }
.finish-file input { font-size: .85rem; max-width: 16rem; }
.purchase { line-height: 1.5; }
.purchase-edit { margin-top: .3rem; }
.purchase-edit summary { font-weight: 550; font-size: .8rem; color: var(--blue); }

/* Editor dos avisos aos vendedores */
.alert-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .alert-editor { grid-template-columns: 1fr; } }
.alert-editor textarea { font-family: inherit; min-height: 12rem; }
.alert-vars { display: flex; flex-wrap: wrap; gap: .35rem; }
.alert-preview { white-space: pre-wrap; background: #dcf8c6; color: #111; border-radius: 14px; padding: .8rem 1rem; margin-top: .3rem; min-height: 10rem; font-size: .92rem; word-break: break-word; }
:root[data-theme="dark"] .alert-preview { background: #144d37; color: #f1f5f2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .alert-preview { background: #144d37; color: #f1f5f2; } }

/* Tags "Fixado" (Forest / Hidraulics): vínculo cliente-vendedor */
.pin-badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; color: #1c1c1e; background: var(--pin, var(--green)); }
.pin-choices { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pin-btn { border: 0; cursor: pointer; font: inherit; font-weight: 700; padding: .55rem 1.1rem; border-radius: 999px; background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--pin, var(--line)); transition: transform .12s, background .15s; }
.pin-btn:hover { transform: translateY(-1px); }
.pin-btn.is-on { background: var(--pin); color: #1c1c1e; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }

/* Fixar cliente: junto ao botão Finalizar, no topo da conversa */
.pin-inline { display: inline-flex; align-items: center; gap: .35rem; margin: 0 .4rem; vertical-align: middle; }
.pin-label { font-weight: 700; font-size: .85rem; }
.pin-inline .pin-btn { padding: .45rem .9rem; font-size: .88rem; }
.pin-remove { border: 0; cursor: pointer; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: .8rem; }
.pin-remove:hover { background: var(--red-soft); color: var(--red); }

/* Período do dashboard: Máximo e Personalizado */
.segmented { position: relative; align-items: center; }
.range-pop { position: relative; }
.range-pop summary { list-style: none; cursor: pointer; padding: .35rem .9rem; border-radius: 999px; font-weight: 550; font-size: .86rem; white-space: nowrap; color: var(--text); }
.range-pop summary::-webkit-details-marker { display: none; }
.range-pop summary.on, .range-pop[open] summary { background: var(--blue); color: #fff; }
.range-form { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 30; display: flex; flex-direction: column; gap: .6rem; min-width: 15rem;
  padding: 1rem; border-radius: 18px; background: var(--glass-strong); box-shadow: var(--shadow-lift); }

/* Fixar cliente dentro da Persona */
.pin-persona { display: flex; flex-direction: column; gap: .4rem; padding: .7rem .8rem; margin: .6rem 0; border-radius: 14px; background: var(--surface-2); }

/* Fixar cliente dentro da Persona */
.pin-persona { display: flex; flex-direction: column; gap: .4rem; padding: .7rem .8rem; margin: .6rem 0; border-radius: 14px; background: var(--surface-2); }

/* Correção: caixa "Personalizado" ficava coberta/cortada pelos cartões abaixo e translúcida */
.hero { position: relative; z-index: 20; }
.segmented { z-index: 21; flex-wrap: wrap; }
.range-form {
  background: #ffffff; color: #1c1c1e; border: 1px solid var(--hairline); z-index: 50;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  width: 16rem; max-width: calc(100vw - 2rem);
}
.range-form label { color: inherit; }
:root[data-theme="dark"] .range-form { background: #2c2c2e; color: #f5f5f7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .range-form { background: #2c2c2e; color: #f5f5f7; } }
@media (max-width: 800px) { .range-form { right: auto; left: 0; } }
.range-pop summary { padding: .35rem .8rem; }

/* Temperatura do contato: quente (anúncio) / frio (disparo) */
.temp-hot { background: rgba(255, 90, 31, .16); color: #e8470f; }
.temp-cold { background: rgba(56, 160, 255, .16); color: #1d7fd6; }
:root[data-theme="dark"] .temp-hot { color: #ff8a5c; }
:root[data-theme="dark"] .temp-cold { color: #7cc4ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .temp-hot { color: #ff8a5c; } :root:not([data-theme="light"]) .temp-cold { color: #7cc4ff; } }

/* Nota dos vendedores (0 a 5): estrelas e faixas de cor */
.score-low { --c: #ef4444; }
.score-mid { --c: #f59e0b; }
.score-good { --c: #84cc16; }
.score-great { --c: #16a34a; }
.score-none { --c: #94a3b8; }
.stars { display: inline-block; font-size: 1.15rem; letter-spacing: .08em; line-height: 1; white-space: nowrap;
  background: linear-gradient(90deg, var(--c, #94a3b8) var(--fill, 0%), rgba(148, 163, 184, .35) var(--fill, 0%)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.score-cell { display: inline-flex; flex-direction: column; align-items: center; gap: .15rem; min-width: 7.5rem; cursor: pointer; border: 0; font: inherit; color: var(--text);
  background: color-mix(in srgb, var(--c, #94a3b8) 14%, transparent); border-radius: 14px; padding: .4rem .7rem; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c, #94a3b8) 55%, transparent); transition: transform .15s, box-shadow .15s; }
.score-cell:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 2px var(--c), 0 6px 16px color-mix(in srgb, var(--c, #94a3b8) 35%, transparent); }
.score-cell strong { font-size: 1.5rem; font-weight: 800; color: var(--c); line-height: 1; }
.score-cell small { font-size: .72rem; font-weight: 700; color: var(--c); }
.score-cell[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--c); }
.kpi-score { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c, #94a3b8) 55%, transparent), var(--shadow); }
.kpi-score strong { color: var(--c); }
.kpi-score small { color: var(--c); font-weight: 700; }
.score-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .8rem; font-weight: 650; margin-bottom: .6rem; }
.score-legend span { color: var(--c); }
.eval-detail td { background: var(--surface-2); }
.eval-detail[hidden] { display: none; }
.eval-bars { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; padding: .4rem .2rem; }
.eval-bar { display: flex; flex-direction: column; gap: .3rem; }
.eval-bar-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .88rem; font-weight: 650; }
.eval-bar-head strong { color: var(--c); }
.eval-track { height: 10px; border-radius: 999px; background: rgba(148, 163, 184, .3); overflow: hidden; }
.eval-track i { display: block; height: 100%; border-radius: 999px; background: var(--c); transition: width .5s var(--ease); }

/* Metas e conquistas */
.goal-banner { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.1rem; margin-bottom: .9rem; border-radius: 18px; color: #fff;
  background: linear-gradient(120deg, #15803d, #16a34a 55%, #eab308); box-shadow: 0 8px 26px rgba(22, 163, 74, .45); animation: goal-pop .5s var(--ease), goal-glow 2.4s ease-in-out infinite .5s; }
.goal-banner > div { flex: 1; display: flex; flex-direction: column; gap: .1rem; }
.goal-banner span:not(.goal-trophy) { opacity: .95; font-size: .9rem; }
.goal-trophy { font-size: 2rem; animation: goal-bounce 1.2s ease-in-out infinite; }
.goal-banner .btn { background: rgba(255, 255, 255, .92); color: #14532d; }
@keyframes goal-pop { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes goal-glow { 0%, 100% { box-shadow: 0 8px 26px rgba(22, 163, 74, .45); } 50% { box-shadow: 0 8px 34px rgba(234, 179, 8, .75); } }
@keyframes goal-bounce { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-5px) rotate(6deg); } }
.goal-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: .9rem; }
.goal-item { display: flex; flex-direction: column; gap: .45rem; padding: .85rem 1rem; border-radius: 16px; background: var(--surface-2); }
.goal-item.is-achieved { box-shadow: inset 0 0 0 2px #16a34a; background: color-mix(in srgb, #16a34a 12%, transparent); }
.goal-item.is-expired { opacity: .65; }
.goal-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .goal-banner, .goal-trophy { animation: none; } }
.reassign-banner { background: linear-gradient(120deg, #b45309, #f59e0b); box-shadow: 0 8px 26px rgba(245, 158, 11, .45); animation: goal-pop .5s var(--ease); }
.reassign-banner .goal-trophy { animation: none; }
.reassign-banner .btn { background: rgba(255, 255, 255, .92); color: #78350f; }

/* Áudio dentro da bolha: o player não pode encolher (antes ficava só com "—" e ⋮) */
.msg-audio { display: block; width: 280px; max-width: 100%; min-width: 240px; height: 40px; margin: .15rem 0 .2rem; }
.msg:has(> .msg-audio) { min-width: 272px; }
@media (max-width: 600px) { .msg-audio { min-width: 200px; width: 100%; } .msg:has(> .msg-audio) { min-width: 0; width: 90%; } }

.field-group { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.2rem; margin: 0; padding: .55rem .8rem .7rem; border: 1px solid var(--border, rgba(148,163,184,.35)); border-radius: 10px; min-width: 0; }
.field-group legend { padding: 0 .35rem; font-size: .85rem; font-weight: 550; }
.field-group label.check { width: auto; margin: 0; }
