/* =============================================================================
   DN Imports · Central de Controle
   Identidade DN Imports: azul profundo → ciano (#0A14E0 · #0038EB · #0078FF · #00B1F9),
   fundo escuro "tech", Sora (títulos/números) + Manrope (texto).
   ============================================================================= */

:root {
  --brand-deep: #0a14e0;
  --brand-royal: #0038eb;
  --brand-electric: #0078ff;
  --brand-cyan: #00b1f9;
  --accent: #5cc8ff;
  --accent-strong: #2f9bff;
  --brand-gradient: linear-gradient(120deg, #0a2fe6, #0078ff 55%, #00b1f9);

  --bg: #05060a;
  --bg-2: #070912;
  --bg-3: #0a0d18;
  --sidebar: #070910;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #eef2fb;
  --text-2: #b9c1d4;
  --muted: #8790a6;
  --faint: #5d667c;

  --green: #2fd27e;
  --green-bg: rgba(47, 210, 126, 0.12);
  --amber: #f5b544;
  --amber-bg: rgba(245, 181, 68, 0.13);
  --red: #f26b6b;
  --red-bg: rgba(242, 107, 107, 0.12);
  --orange: #fb8a4a;
  --orange-bg: rgba(251, 138, 74, 0.13);
  --blue-bg: rgba(0, 120, 255, 0.14);
  --slate-bg: rgba(148, 163, 184, 0.12);

  --mobile-bar-h: 56px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font-display: "Sora", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
svg { width: 16px; height: 16px; flex: none; }
.sys svg, .note h4 svg, .pill svg { width: 14px; height: 14px; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(ellipse 900px 600px at 70% -10%, rgba(0, 56, 235, 0.16), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 100%, rgba(0, 177, 249, 0.07), transparent 65%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(0, 120, 255, 0.45); }
:focus-visible { outline: 2px solid var(--brand-cyan); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.96), rgba(6, 8, 14, 0.98));
  border-right: 1px solid var(--border); padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 20px; }
.brand img { height: 40px; width: auto; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.1; }
.brand-sub { font-family: var(--font-display); font-weight: 600; font-size: 9.5px; letter-spacing: 2.2px; color: var(--accent); text-transform: uppercase; line-height: 1.25; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1.8px; color: var(--faint); text-transform: uppercase; padding: 10px 8px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 13.5px; text-decoration: none; border: 1px solid transparent;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active {
  background: linear-gradient(120deg, rgba(10, 47, 230, 0.32), rgba(0, 120, 255, 0.16));
  border-color: rgba(0, 120, 255, 0.45); color: #fff;
}
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.health-card { border-radius: 12px; padding: 11px 12px; background: var(--green-bg); border: 1px solid rgba(47, 210, 126, 0.25); font-size: 12px; color: var(--text-2); }
.health-card strong { display: flex; align-items: center; gap: 7px; color: var(--green); font-size: 12.5px; margin-bottom: 2px; }
.health-card.warn { background: var(--amber-bg); border-color: rgba(245, 181, 68, 0.3); }
.health-card.warn strong { color: var(--amber); }
.health-card.bad { background: var(--red-bg); border-color: rgba(242, 107, 107, 0.3); }
.health-card.bad strong { color: var(--red); }
.user { display: flex; align-items: center; gap: 10px; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #fff; background: var(--brand-gradient);
}
.user-name { font-weight: 700; font-size: 12.5px; }
.user-role { color: var(--muted); font-size: 11px; }
.user .icon-btn { margin-left: auto; }

.main { min-width: 0; padding: 26px 30px 40px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 2.6px; color: var(--accent); text-transform: uppercase; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.3px; margin: 2px 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-note { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- cartões */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; margin: 0; }
.card-head .link { margin-left: auto; font-weight: 700; font-size: 12.5px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }

/* status de serviço */
.svc { padding: 14px 15px; }
.svc-name { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.svc-status { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 6px 0 2px; }
.svc-detail { font-size: 11.5px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(47, 210, 126, 0.7); flex: none; }
.dot.warn { background: var(--amber); box-shadow: 0 0 10px rgba(245, 181, 68, 0.6); }
.dot.bad { background: var(--red); box-shadow: 0 0 10px rgba(242, 107, 107, 0.6); }
.dot.off { background: var(--faint); box-shadow: none; }

/* indicadores */
.kpi { padding: 18px 18px 16px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.1; margin: 8px 0 6px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-sub b { color: var(--text); font-weight: 700; }
.kpi.primary { background: linear-gradient(140deg, rgba(10, 47, 230, 0.35), rgba(0, 56, 235, 0.08) 60%); border-color: rgba(0, 120, 255, 0.45); }
.kpi.amber { border-color: rgba(245, 181, 68, 0.38); background: linear-gradient(140deg, rgba(245, 181, 68, 0.08), transparent 60%); }
.kpi.amber .kpi-value { color: var(--amber); }
.kpi.orange .kpi-value { color: var(--orange); }
.kpi.red .kpi-value { color: var(--red); }
.kpi.green .kpi-value { color: var(--green); }
.accent { color: var(--accent); font-weight: 700; }
.kpi-bars { display: flex; align-items: flex-end; gap: 4px; height: 52px; }
.kpi-bars span { flex: 1; border-radius: 3px 3px 1px 1px; background: rgba(0, 120, 255, 0.45); min-height: 4px; }
.kpi-bars span.now { background: var(--brand-cyan); box-shadow: 0 0 12px rgba(0, 177, 249, 0.6); }

/* ------------------------------------------------------------ chips/pills */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 999px; font-size: 11px; font-weight: 800; background: var(--blue-bg); color: var(--accent);
}
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
}
.pill.blue { background: var(--blue-bg); color: var(--accent); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.slate { background: var(--slate-bg); color: #b9c3d6; }
.pill.outline { background: transparent; border-color: var(--border-strong); }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: 12px; font-size: 12.5px; color: var(--text-2);
  background: var(--green-bg); border: 1px solid rgba(47, 210, 126, 0.3); }
.live b { color: var(--green); }
.live.paused { background: var(--amber-bg); border-color: rgba(245, 181, 68, 0.35); }
.live.paused b { color: var(--amber); }

/* filtros (abas em pílula) */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); font-weight: 700; font-size: 12.5px;
}
.tab:hover { background: var(--surface); color: var(--text); }
.tab.active { background: rgba(0, 120, 255, 0.16); border-color: rgba(0, 120, 255, 0.5); color: #fff; }
.tab .count { color: var(--muted); font-weight: 700; }
.tab .tdot { width: 7px; height: 7px; border-radius: 50%; }

/* ------------------------------------------------------------- botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.04); color: var(--text);
  font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 10px 26px rgba(0, 110, 255, 0.35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(242, 107, 107, 0.45); color: #ff9a9a; background: rgba(242, 107, 107, 0.06); }
.btn.danger:hover { background: rgba(242, 107, 107, 0.14); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); padding-inline: 6px; }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.03); color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

/* -------------------------------------------------------- formulários */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.hint { font-size: 11.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-strong); color: var(--text); font-weight: 600; font-size: 13.5px; outline: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; font-weight: 500; }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(0, 150, 255, 0.7); box-shadow: 0 0 0 3px rgba(0, 120, 255, 0.18); }
.input.sm { padding: 7px 10px; font-size: 13px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search .input { padding-left: 36px; }
.head-search { width: 300px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* chave liga/desliga */
.switch { position: relative; width: 44px; height: 25px; flex: none; cursor: pointer; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); transition: background 0.15s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #e9eef8;
  transition: transform 0.15s; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.switch input:checked + span { background: var(--brand-gradient); }
.switch input:checked + span::after { transform: translateX(19px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand-cyan); outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .t { font-weight: 700; font-size: 13px; }
.toggle-row .d { font-size: 11.5px; color: var(--muted); }
.toggle-row .switch { margin-left: auto; }

/* contador +/- */
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.04);
  color: var(--text); cursor: pointer; font-weight: 800; line-height: 1;
}
.stepper button:hover { background: var(--surface-hover); }
.stepper .v { min-width: 26px; text-align: center; font-weight: 800; }
.stepper .v.low { color: var(--amber); }
.stepper .v.zero { color: var(--red); }
.number-input { width: 78px; text-align: center; }

/* ------------------------------------------------------------- tabelas */
.table-wrap { overflow: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
  font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover, .table tbody tr.selected { background: rgba(255, 255, 255, 0.035); }
.table .price { font-family: var(--font-display); font-weight: 700; color: var(--accent); white-space: nowrap; }
.table .strike { text-decoration: line-through; color: var(--faint); margin-right: 6px; }
.table .new { color: var(--amber); font-weight: 800; }
.prod-name { font-weight: 700; }
.prod-sub { font-size: 11.5px; color: var(--muted); }

/* lista (atendimentos, eventos...) */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: rgba(255, 255, 255, 0.03); }
.li-main { min-width: 0; flex: 1; }
.li-title { font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.li-title .phone { color: var(--muted); font-weight: 600; font-size: 12px; }
.li-sub { color: var(--text-2); font-size: 12.5px; }
.li-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 800; font-family: var(--font-display); font-size: 13px; }

/* eventos */
.ev-row { display: flex; gap: 10px; padding: 11px 18px; border-top: 1px solid var(--border); }
.ev-row:first-child { border-top: 0; }
.ev-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.ev-dot.error { background: var(--red); }
.ev-dot.warning { background: var(--amber); }
.ev-dot.info { background: var(--accent); }
.ev-title { font-weight: 700; font-size: 13px; }
.ev-sub { color: var(--muted); font-size: 12px; }
.level-pill.error { background: var(--red-bg); color: var(--red); }
.level-pill.warning { background: var(--amber-bg); color: var(--amber); }
.level-pill.info { background: var(--slate-bg); color: #b9c3d6; }
.result.ok { color: var(--green); font-weight: 700; }
.result.bad { color: #ff9a9a; font-weight: 700; }
.result.neutral { color: var(--text-2); font-weight: 700; }
.codebox {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: #c8d3ea; white-space: pre-wrap; word-break: break-word;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}

/* ação da IA */
.act { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); }
.act:first-child { border-top: 0; }
.act-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--blue-bg); color: var(--accent); flex: none; }
.act-ic svg { width: 15px; height: 15px; }
.act-ic.handoff { background: var(--amber-bg); color: var(--amber); }

/* ------------------------------------------------------ atendimentos */
/* Tela "cheia": ocupa exatamente a área visível; só a lista e as mensagens rolam (cada uma na sua coluna) */
.main.full { padding: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.inbox {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(260px, 320px);
}
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox-list .head { padding: 20px 16px 12px; display: flex; flex-direction: column; gap: 12px; flex: none; }
.inbox-list .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
.inbox-list .tabs::-webkit-scrollbar { display: none; }
.inbox-list .tab { padding: 6px 11px; flex: none; }
.inbox-items { overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.inbox .back-btn { display: none; }
.conv { display: flex; gap: 11px; padding: 13px 16px; cursor: pointer; border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.conv:hover { background: rgba(255, 255, 255, 0.025); }
.conv.active { background: rgba(0, 120, 255, 0.08); border-left-color: var(--brand-electric); }
.conv.waiting { border-left-color: var(--amber); }
.conv .preview { color: var(--text-2); font-size: 12.5px; }
.conv .tags { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex: none; min-width: 0; }
.chat-head .li-main { min-width: 0; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: min(72%, 640px); padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg { position: relative; }
.msg.img { padding: 5px; width: min(310px, 100%); white-space: normal; }
.msg.img .cap { white-space: pre-wrap; }
/* Opções da mensagem (⌄): ao lado do balão, aparece ao passar o mouse (sempre visível no celular) */
.msg-opt {
  position: absolute; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--text-2); cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.msg.out .msg-opt { right: calc(100% + 6px); }
.msg.in .msg-opt { left: calc(100% + 6px); }
.msg:hover .msg-opt, .msg.menu-open .msg-opt, .msg-opt:focus-visible { opacity: 1; }
.msg-opt:hover { color: var(--text); background: var(--surface-hover); }
.msg-opt svg { width: 15px; height: 15px; }
@media (hover: none) { .msg-opt { opacity: 0.7; } }
.msg-menu { top: calc(100% + 6px); white-space: normal; min-width: 220px; }
.msg.out .msg-menu { right: 0; }
.msg.in .msg-menu { left: 0; right: auto; }
.msg-menu.up { top: auto; bottom: calc(100% + 6px); }
.msg-menu button { display: flex; align-items: center; gap: 8px; }
.msg-menu svg { width: 15px; height: 15px; }
.menu-hint { padding: 6px 10px 4px; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.msg.deleted { display: inline-flex; align-items: center; gap: 7px; font-style: italic; color: var(--muted); background: rgba(255, 255, 255, 0.03); border: 1px dashed var(--border-strong); }
.msg.deleted svg { width: 13px; height: 13px; }
.msg.img img { display: block; width: 100%; max-height: 340px; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: rgba(0, 0, 0, 0.25); min-height: 120px; }
.msg.img .cap { padding: 7px 9px 4px; }
.lightbox img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 12px; }
.msg.in { align-self: flex-start; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: linear-gradient(140deg, rgba(10, 47, 230, 0.55), rgba(0, 90, 220, 0.4)); border: 1px solid rgba(0, 120, 255, 0.45); border-bottom-right-radius: 4px; }
.msg.human { background: linear-gradient(140deg, rgba(20, 150, 110, 0.38), rgba(20, 120, 90, 0.25)); border-color: rgba(47, 210, 126, 0.4); }
.msg.failed { border-color: var(--red); }
.msg-meta { font-size: 10.5px; color: var(--muted); margin-top: -4px; }
.msg-meta.right { align-self: flex-end; }
.sys { align-self: center; display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--blue-bg); color: var(--accent); border: 1px solid rgba(0, 120, 255, 0.3); }
.sys.amber { background: var(--amber-bg); color: var(--amber); border-color: rgba(245, 181, 68, 0.3); }
.sys.green { background: var(--green-bg); color: var(--green); border-color: rgba(47, 210, 126, 0.3); }
.composer { flex: none; border-top: 1px solid var(--border); background: rgba(6, 8, 14, 0.55); }
.chat-foot { padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.chat-foot .input { flex: 1; min-width: 0; }
.attach-btn { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.attach-btn svg { width: 18px; height: 18px; }
.attachment { display: flex; align-items: center; gap: 12px; margin: 12px 16px 0; padding: 8px 10px; border-radius: 12px; border: 1px solid rgba(0, 120, 255, 0.4); background: rgba(0, 120, 255, 0.08); }
.attachment img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; }
.attachment .meta { min-width: 0; flex: 1; }
.chat.dragging .chat-body { outline: 2px dashed rgba(0, 150, 255, 0.6); outline-offset: -10px; background: rgba(0, 120, 255, 0.05); }
.btn .spinner { width: 15px; height: 15px; border-width: 2px; }
.side { padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; min-height: 0; min-width: 0; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 7px 10px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }
.note { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); }
.note h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 7px; }
.note.ai { border-color: rgba(0, 120, 255, 0.35); background: rgba(0, 120, 255, 0.07); }
.note.ai h4 { color: var(--accent); }
.note.amber { border-color: rgba(245, 181, 68, 0.35); background: var(--amber-bg); }
.note.amber h4 { color: var(--amber); }
.side .actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

/* -------------------------------------------------------------- leads */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.col { background: rgba(255, 255, 255, 0.025); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 12px; min-height: 240px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 12px; font-family: var(--font-display); font-weight: 600; }
.col-head .sq { width: 9px; height: 9px; border-radius: 3px; }
.col-head .n { margin-left: auto; color: var(--muted); font-size: 12px; font-family: var(--font-body); font-weight: 700; }
.lead { position: relative; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px; }
.lead-foot .icon-btn { width: 28px; height: 28px; font-weight: 800; letter-spacing: 1px; }
/* Lead aberto pelo Atendimento ("Ver no funil de leads") */
.lead.focus { border-color: var(--brand-electric); background: rgba(0, 120, 255, 0.09); box-shadow: 0 0 0 2px rgba(0, 120, 255, 0.35), 0 10px 30px rgba(0, 90, 255, 0.22); scroll-margin: 90px; }
.lead.focus.pulse { animation: lead-pulse 1.2s ease-out 3; }
.lead-flag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; color: var(--accent); background: var(--blue-bg); border: 1px solid rgba(0, 120, 255, 0.35); }
.lead-flag svg { width: 12px; height: 12px; }
.col.has-focus { border-color: rgba(0, 120, 255, 0.45); }
@keyframes lead-pulse { 0% { box-shadow: 0 0 0 0 rgba(0, 150, 255, 0.65); } 100% { box-shadow: 0 0 0 14px rgba(0, 150, 255, 0); } }
@media (prefers-reduced-motion: reduce) { .lead.focus.pulse { animation: none; } }
/* Catálogo: várias cores por produto */
.color-list { display: flex; flex-direction: column; gap: 8px; }
.color-row { display: flex; align-items: center; gap: 6px; }
.color-row .input { flex: 1; min-width: 0; }
.color-row .icon-btn { flex: none; width: 38px; height: 38px; font-size: 18px; font-weight: 800; }
.menu {
  position: absolute; right: 10px; top: calc(100% - 6px); z-index: 20; min-width: 230px; padding: 6px;
  background: #0f1322; border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.menu button { text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-weight: 700; font-size: 12.5px; cursor: pointer; }
.menu button:hover { background: var(--surface-hover); }
.menu button.danger { color: #ff9a9a; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.lead-top { display: flex; align-items: center; gap: 8px; }
.lead-name { font-weight: 800; }
.lead-top .pill { margin-left: auto; }
.lead-prod { font-weight: 700; font-size: 12.5px; margin: 6px 0 4px; }
.lead-note { font-size: 12px; color: var(--text-2); }
.lead-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); }
.lead-foot .t { color: var(--muted); font-size: 11.5px; margin-right: auto; }
.lead-foot .btn.sm { padding: 5px 9px; font-size: 11.5px; }

/* ----------------------------------------------------------- catálogo */
.catalog { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.thumb { width: 38px; height: 38px; border-radius: 9px; border: 1px dashed var(--border-strong); display: grid; place-items: center; font-size: 10px; color: var(--muted); flex: none; }
.editor { position: sticky; top: 20px; }

/* ----------------------------------------------------------- planilhas */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.step { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.step .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; background: var(--surface-2); flex: none; }
.step.done .num { background: var(--green-bg); color: var(--green); }
.step.current { border-color: rgba(0, 120, 255, 0.5); background: rgba(0, 120, 255, 0.1); }
.step.current .num { background: var(--brand-gradient); color: #fff; }
.step .t { font-weight: 800; font-size: 13px; }
.step .d { font-size: 11.5px; color: var(--muted); }
.drop {
  border: 1.5px dashed rgba(0, 150, 255, 0.45); border-radius: var(--radius); padding: 26px; text-align: center; cursor: pointer;
  background: rgba(0, 120, 255, 0.05); transition: background 0.15s;
}
.drop:hover, .drop.over { background: rgba(0, 120, 255, 0.12); }
.drop .big { font-family: var(--font-display); font-weight: 600; font-size: 15px; margin: 8px 0 4px; }
.file-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); border: 1.5px dashed rgba(0, 150, 255, 0.4); background: rgba(0, 120, 255, 0.05); }
.file-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--green-bg); color: var(--green); flex: none; }
.stat { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 24px; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat.amber { border-color: rgba(245, 181, 68, 0.4); } .stat.amber .v { color: var(--amber); }
.stat.blue .v { color: var(--accent); }
.stat.red .v { color: var(--red); }
.applybar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); margin-top: 14px; }

/* ---------------------------------------------------------- IA e fluxos */
.savebar {
  position: sticky; bottom: 14px; display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: 14px;
  background: rgba(12, 15, 26, 0.92); border: 1px solid var(--border-strong); backdrop-filter: blur(10px); box-shadow: var(--shadow);
}
.savebar.dirty { border-color: rgba(0, 120, 255, 0.55); }
.flow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flow-box { padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(0, 120, 255, 0.4); background: rgba(0, 120, 255, 0.08); font-weight: 700; font-size: 12px; text-align: center; }
.flow-line { flex: 1; min-width: 20px; height: 2px; background: linear-gradient(90deg, rgba(0, 120, 255, 0.6), rgba(0, 177, 249, 0.6)); }
.hours { display: grid; grid-template-columns: 90px 1fr 1fr 70px; gap: 8px 10px; align-items: center; }
.hours .d { font-weight: 700; font-size: 12.5px; }

/* --------------------------------------------- monitoramento/gráficos */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; padding-top: 8px; }
.chart .bar { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; min-width: 6px; height: 100%; }
.chart .bar span { display: block; border-radius: 2px; }
.chart .bar .e { background: var(--red); }
.chart .bar .w { background: var(--amber); }
.chart .bar .z { background: rgba(255, 255, 255, 0.06); height: 2px; }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); margin-left: auto; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.avail { display: grid; grid-template-columns: 96px 1fr 58px; gap: 10px; align-items: center; padding: 6px 0; }
.avail .n { font-weight: 700; font-size: 12.5px; }
.avail .bars { display: flex; gap: 2px; height: 18px; }
.avail .bars span { flex: 1; border-radius: 2px; background: var(--green); opacity: 0.9; }
.avail .bars span.mid { background: var(--amber); }
.avail .bars span.bad { background: var(--red); }
.avail .bars span.na { background: rgba(255, 255, 255, 0.07); }
.avail .p { text-align: right; font-weight: 800; font-size: 12px; color: var(--green); }
.ev-table td { font-size: 12.5px; }
.ev-detail td { padding-top: 0; }

/* -------------------------------------------------------- manutenção */
.svc-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.svc-row:first-of-type { border-top: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 700; font-size: 12.5px; }
.chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--red); }
.backup { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); }
.backup:first-of-type { border-top: 0; }
.danger-card { border-color: rgba(242, 107, 107, 0.35); background: linear-gradient(140deg, rgba(242, 107, 107, 0.07), transparent 70%); }

/* -------------------------------------------------- modal/toast/vazio */
.modal-back { position: fixed; inset: 0; background: rgba(2, 4, 10, 0.72); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: #0c0f1b; border: 1px solid var(--border-strong); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.modal.wide { width: min(760px, 100%); }
.modal h3 { font-family: var(--font-display); margin: 0 0 6px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.qr { display: grid; place-items: center; padding: 18px; background: #fff; border-radius: 14px; margin: 14px auto; width: 280px; height: 280px; }
.qr img { width: 244px; height: 244px; image-rendering: pixelated; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 12px; background: #0f1322; border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.toast.ok { border-color: rgba(47, 210, 126, 0.45); }
.toast.err { border-color: rgba(242, 107, 107, 0.5); }
.toast .ti { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--accent); }
.toast.ok .ti { background: var(--green); } .toast.err .ti { background: var(--red); }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; opacity: 0.6; margin-bottom: 8px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.12); border-top-color: var(--brand-cyan); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* -------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); padding: 32px 28px; border-radius: 22px; background: rgba(12, 15, 26, 0.85); border: 1px solid var(--border-strong); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; width: 360px; height: 360px; right: -160px; top: -180px; border-radius: 50%; background: radial-gradient(circle, rgba(0, 160, 255, 0.22), transparent 62%); pointer-events: none; }
.login-card .brand { padding: 0 0 22px; }
.login-card h1 { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; }
.login-error { color: #ff9a9a; font-weight: 700; font-size: 12.5px; min-height: 18px; }

/* --------------------------------------------------------- responsivo */
.mobile-bar { display: none; }
@media (max-width: 1280px) {
  .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Ficha do lead vira um painel que abre pelo botão (i) */
  .inbox { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .inbox .side { display: none; }
  .inbox.show-side { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(250px, 290px); }
  .inbox.show-side .side { display: flex; }
}
@media (max-width: 1080px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .catalog, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; min-height: calc(100dvh - var(--mobile-bar-h)); }
  .sidebar { position: fixed; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; height: var(--mobile-bar-h); padding: 0 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; background: rgba(6, 8, 14, 0.94); backdrop-filter: blur(8px); }
  .mobile-bar img { height: 28px; }
  .main { padding: 18px 16px 30px; }
  .cols-2, .cols-4, .steps, .form-grid, .kanban { grid-template-columns: minmax(0, 1fr); }
  .cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .svc { padding: 12px; }
  .page-head .actions, .page-head .actions .search { width: 100%; }
  /* Celular: uma coluna por vez (lista → conversa → ficha), na altura exata da tela */
  .main.full { height: calc(100dvh - var(--mobile-bar-h)); }
  .inbox, .inbox.show-side { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-chat .inbox-list { display: none; }
  .inbox:not(.has-chat) .chat { display: none; }
  .inbox.show-side.has-chat .chat { display: none; }
  .inbox .back-btn { display: inline-grid; }
  .chat-head { padding: 10px 12px; gap: 10px; }
  .chat-head .pill { display: none; }
  .chat-body { padding: 14px 12px; }
  .chat-foot { padding: 10px; gap: 8px; }
  .chat-foot .btn.primary .label { display: none; }
  .attachment { margin: 10px 10px 0; }
  .msg { max-width: 88%; }
  .page-title { font-size: 22px; }
  .hours { grid-template-columns: 70px 1fr 1fr; }
  .hours .closed { grid-column: 1 / -1; }
}
