/* ============================================================
   KDS Análises — preto + vermelho (identidade KEYROZ/KDS)
   ============================================================ */

:root {
  --bg: #0d0d0d;
  --bg-soft: #111111;
  --bg-panel: #171717;
  --surface: #1a1a1a;
  --surface-2: #202020;
  --surface-3: #262626;
  --line: #2e2e2e;
  --line-strong: #3a3a3a;
  --text: #fafafa;
  --text-soft: #e5e5e5;
  --muted: #adadad;
  --muted-2: #8c8c8c;
  /* --accent é usado como fundo com texto branco: precisa de >= 4.5:1 (5.1:1) */
  --accent: #d81b2a;
  --accent-hover: #c81727;
  --accent-2: #ff4d5a;
  --accent-soft: rgba(216, 27, 42, 0.12);
  --accent-line: rgba(216, 27, 42, 0.34);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --blue: #b5b5b5;
  --blue-soft: rgba(255, 255, 255, 0.05);
  --purple: #ff8a92;
  --purple-soft: rgba(216, 27, 42, 0.08);
  --radius: 12px;
  --radius-sm: 10px;
  --nav-h: 72px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(1000px 640px at 50% -18%, rgba(216, 27, 42, 0.18), transparent 62%),
    radial-gradient(800px 500px at 100% 10%, rgba(216, 27, 42, 0.06), transparent 60%),
    radial-gradient(600px 420px at 5% 100%, rgba(216, 27, 42, 0.05), transparent 65%),
    var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 50% 0%, black, transparent 72%);
  z-index: 0;
}

::selection { background: rgba(216, 27, 42, 0.35); color: #fff; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(216, 27, 42, 0.35); background-clip: padding-box; }

.boot {
  height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--muted);
  position: relative;
  z-index: 1;
}
.boot-mark { display: flex; gap: 6px; }
.boot-mark span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  animation: bootPulse 1s ease-in-out infinite;
}
.boot-mark span:nth-child(2) { animation-delay: 0.15s; }
.boot-mark span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bootPulse { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
.noscript { padding: 32px; color: var(--text); }

/* ------------------------------------------------------------- gate */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
  overflow: auto;
}
.gate-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #171717;
  box-shadow: 0 0 80px rgba(216, 27, 42, 0.1), var(--shadow);
  backdrop-filter: blur(16px);
}
.gate-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.gate-logo .mark { width: 42px; height: 42px; }
.gate h1 { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.03em; margin: 0 0 6px; }
.gate p { color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }
.gate .field { margin-bottom: 14px; }
.gate .btn { width: 100%; justify-content: center; }
.gate-foot { margin-top: 18px; font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }

/* ------------------------------------------------------------- shell */

.app-shell { height: 100dvh; width: 100%; max-width: 100vw; display: flex; flex-direction: column; position: relative; z-index: 1; overflow: hidden; }

.topbar {
  height: var(--nav-h);
  flex: 0 0 var(--nav-h);
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 22px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px) saturate(1.2);
  position: relative;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.mark { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: transparent;
  background: linear-gradient(100deg, #ff4d5a 0%, #d81b2a 55%, #b0141f 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.brand-text span { font-size: 8.5px; letter-spacing: 0.34em; text-transform: uppercase; color: var(--muted-2); margin-top: 4px; }

.tabs { display: flex; align-items: center; gap: 4px; height: 100%; flex: 1 1 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  white-space: nowrap;
  transition: 160ms ease;
}
.tab:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.tab.active { color: var(--text); background: var(--accent-soft); border-color: var(--accent-line); }
.tab.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -15px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}
.tab svg { width: 15px; height: 15px; opacity: 0.9; }
.tab .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); color: var(--text-soft);
  font-size: 10.5px; display: inline-grid; place-items: center;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.company-select {
  appearance: none;
  height: 34px;
  padding: 0 30px 0 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23adadad' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text-soft);
  font-size: 12px;
  max-width: 180px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.14); }
.status-pill.off .status-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.14); }
.status-pill.err .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.14); }
.auth-pill { display: inline-flex; text-transform: uppercase; letter-spacing: 0.08em; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  color: var(--muted); transition: 160ms ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }

.main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.main-inner { padding: 28px 30px 110px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------------------- type */

.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: rgba(216, 27, 42, 0.06);
  font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-2); font-weight: 600;
  line-height: 1.2;
}
.eyebrow::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px rgba(216, 27, 42, 0.8);
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.025em; margin: 0; font-weight: 700; }
h1 { font-size: clamp(30px, 3.4vw, 40px); line-height: 1.08; letter-spacing: -0.035em; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
.sub { color: var(--muted); font-size: 13.5px; max-width: 680px; margin: 10px 0 0; }
.mono { font-family: var(--font-mono); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { margin-top: 10px; }
.page-head .actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-soft); font-size: 12.5px; font-weight: 500;
  transition: 160ms ease; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent); color: #ffffff; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px;
  box-shadow: 0 4px 14px rgba(216, 27, 42, 0.28);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #ffffff; box-shadow: 0 6px 20px rgba(216, 27, 42, 0.36); }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.28); background: var(--danger-soft); }
.btn-ghost { background: transparent; }
.btn-sm { height: 31px; padding: 0 10px; font-size: 11px; border-radius: 5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.loading { pointer-events: none; opacity: 0.7; }

/* ------------------------------------------------------------- stats */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
  position: relative; overflow: hidden;
  padding: 17px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #171717;
}
.stat-card::after {
  content: ""; position: absolute; width: 110px; height: 110px; right: -34px; top: -52px;
  border-radius: 50%; background: radial-gradient(circle, rgba(216, 27, 42, 0.2), transparent 70%);
}
.stat-card.is-skeleton::after { display: none; }
.stat-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted-2); }
.stat-value { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.04em; margin-top: 5px; line-height: 1; font-weight: 700; }
.stat-hint { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ------------------------------------------------------------- toolbar */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #141414;
}
.search {
  position: relative; flex: 1 1 260px; min-width: 210px;
}
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.search input {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border-radius: 6px; border: 1px solid var(--line); background: #101010;
  color: var(--text); outline: none; font-size: 12.5px;
}
.search input::placeholder { color: var(--muted-2); }
.search input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(216, 27, 42, 0.1); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 11.5px; transition: 150ms ease; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { color: #ffffff; border-color: var(--accent); background: var(--accent); }
.select {
  height: 36px; padding: 0 30px 0 11px; border-radius: 6px;
  border: 1px solid var(--line); background: #101010;
  color: var(--text-soft); font-size: 12px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23adadad' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* ------------------------------------------------------------- table */

.table-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #141414;
  overflow: hidden;
}
.table-head, .contact-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.7fr) 110px minmax(140px, 0.9fr) 130px 92px 78px 22px;
  gap: 14px; align-items: center;
  padding: 0 18px;
}
.table-head {
  height: 42px; border-bottom: 1px solid var(--line);
  font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--muted-2); background: #171717;
}
.contact-row {
  height: 70px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: 150ms ease; position: relative;
}
.contact-row:last-child { border-bottom: none; }
.contact-row:hover { background: rgba(216, 27, 42, 0.05); }
.contact-row:hover .avatar { border-color: var(--accent-line); color: var(--accent-2); }
.contact-row:hover .chev { transform: translateX(3px); color: var(--accent-2); }
.contact-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(216, 27, 42, 0.1);
  border: 1px solid rgba(216, 27, 42, 0.24); color: #ffb3b8;
  font-family: var(--font-display); font-size: 12.5px; font-weight: 600;
  transition: 150ms ease;
}
.contact-name { min-width: 0; }
.contact-name strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-name span { display: block; font-size: 11px; color: var(--muted-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-muted { font-size: 11.5px; color: var(--muted); }
.cell-strong { font-size: 12px; color: var(--text-soft); }
.cell-time { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.cell-time div { color: var(--text-soft); }
.cell-time span { display: block; color: var(--muted-2); font-size: 10.5px; margin-top: 1px; }
.cell-time strong { display: block; color: var(--text-soft); font-weight: 500; }
.chev { color: var(--muted-2); transition: 160ms ease; display: grid; place-items: center; }
.chev svg { width: 15px; height: 15px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-green { color: #6ee7b7; background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.24); }
.badge-amber { color: #fcd34d; background: var(--warn-soft); border-color: rgba(251, 191, 36, 0.22); }
.badge-red { color: #ffb3b8; background: rgba(216, 27, 42, 0.1); border-color: rgba(216, 27, 42, 0.28); }
.badge-blue { color: #d4d4d4; background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.badge-purple { color: #ffb3b8; background: rgba(216, 27, 42, 0.07); border-color: rgba(216, 27, 42, 0.2); }
.badge-muted { color: var(--muted); background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.badge-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.score {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 6px;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface);
}
.score.good { color: #6ee7b7; border-color: rgba(16, 185, 129, 0.28); background: rgba(16, 185, 129, 0.1); }
.score.mid { color: #fcd34d; border-color: rgba(251, 191, 36, 0.25); background: var(--warn-soft); }
.score.bad { color: #ffb3b8; border-color: rgba(216, 27, 42, 0.28); background: var(--accent-soft); }
.score.none { color: var(--muted-2); }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 4px 0; color: var(--muted); font-size: 11.5px; flex-wrap: wrap;
}
.pagination .pages { display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------- empty / skeleton */

.empty {
  padding: 46px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
}
.empty-icon {
  width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 10px;
  display: grid; place-items: center; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.empty-icon svg { width: 21px; height: 21px; }
.empty h3 { font-size: 15px; margin-bottom: 5px; }
.empty p { color: var(--muted); font-size: 12.5px; margin: 0 auto 16px; max-width: 420px; }

.skeleton { border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.07), rgba(255,255,255,.03)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-row { height: 70px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 18px; }
.skeleton-line { height: 12px; }
/* skeleton dos stat cards: mesma caixa do card real (label 9.5px, valor 28px, hint 11px) */
.stat-skel-label { width: 64%; height: 10px; }
.stat-skel-value { width: 46%; height: 27px; margin-top: 6px; border-radius: 5px; }
.stat-skel-hint { width: 74%; height: 10px; margin-top: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ------------------------------------------------------------- detail */

.back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link svg { width: 14px; height: 14px; }

.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background:
    radial-gradient(420px 150px at 0% 0%, rgba(216, 27, 42, 0.1), transparent 70%),
    #171717;
  margin-bottom: 14px; flex-wrap: wrap;
}
.detail-person { display: flex; gap: 14px; align-items: center; min-width: 0; }
.detail-person .avatar { width: 52px; height: 52px; border-radius: 10px; font-size: 17px; }
.detail-person h1 { font-size: 26px; overflow-wrap: anywhere; }
.detail-person .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric {
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #171717;
}
.metric .k { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); }
.metric .v { font-size: 14px; font-weight: 600; margin-top: 3px; color: var(--text-soft); }
.metric .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr); gap: 14px; align-items: start; }

.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #171717;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 17px; border-bottom: 1px solid var(--line);
  background: #1a1a1a;
}
.panel-head h3 { font-size: 13.5px; letter-spacing: -0.01em; }
.panel-head .sub { margin: 2px 0 0; font-size: 11px; }
.panel-body { padding: 16px 17px; }

.conversation {
  max-height: calc(100dvh - 335px);
  min-height: 380px;
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 7px;
  background:
    radial-gradient(600px 260px at 50% 0%, rgba(216, 27, 42, 0.04), transparent 70%),
    #101010;
}
.day-sep { align-self: center; margin: 12px 0 6px; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); display: flex; align-items: center; gap: 10px; width: 100%; }
.day-sep::before, .day-sep::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; }
.msg-in { align-self: flex-start; background: #1a1a1a; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: rgba(216, 27, 42, 0.1); border: 1px solid rgba(216, 27, 42, 0.25); border-bottom-right-radius: 4px; }
.msg-system { align-self: center; max-width: 90%; font-size: 10.5px; color: var(--muted-2); background: rgba(255, 255, 255, 0.03); padding: 4px 10px; border-radius: 999px; }
.msg-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 9.5px; color: var(--muted-2); }
.msg-out .msg-meta { justify-content: flex-end; }
.msg-who { font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 2px; }
.load-older { align-self: center; margin: 6px 0 10px; }

.analysis-score { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.ring { --p: 0; position: relative; width: 86px; height: 86px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255, 255, 255, 0.075) 0); display: grid; place-items: center; }
.ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #171717; border: 1px solid rgba(255, 255, 255, 0.05); }
.ring strong { position: relative; z-index: 1; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.04em; line-height: 1; }
.ring small { position: relative; z-index: 1; font-size: 9px; color: var(--muted-2); line-height: 1; margin-top: 2px; }
.ring-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.analysis-score .tags { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.analysis-section { padding-top: 13px; margin-top: 13px; border-top: 1px solid var(--line); }
.analysis-section .k { font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 5px; }
.analysis-section p { margin: 0; font-size: 12.5px; color: var(--text-soft); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.analysis-section .md { font-size: 12.5px; color: var(--text-soft); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #1a1a1a; }
.kv .k { font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted-2); }
.kv .v { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------- analyses cards */

.analysis-list { display: flex; flex-direction: column; gap: 12px; }
.analysis-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #171717;
  overflow: hidden; transition: 160ms ease;
}
.analysis-card:hover { border-color: rgba(216, 27, 42, 0.22); }
.analysis-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 17px 18px; flex-wrap: wrap; }
.analysis-card-head h3 { font-size: 15px; margin-bottom: 5px; }
.analysis-card-head .meta { display: flex; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.analysis-card-body { padding: 0 18px 18px; }
.analysis-card-body .md { color: var(--text-soft); }
.analysis-card.collapsed .analysis-card-body { display: none; }
.analysis-card:not(.collapsed) .head-summary { display: none; }
.analysis-card .summary { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------- settings */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #171717;
  overflow: hidden;
}
.card-head { padding: 17px 18px 0; }
.card-head h3 { font-size: 15px; }
.card-head p { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.card-body { padding: 16px 18px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; }
.field .hint { font-size: 10.5px; color: var(--muted-2); line-height: 1.45; }
.input, .textarea {
  width: 100%; border-radius: 6px; border: 1px solid var(--line);
  background: #101010; color: var(--text);
  padding: 10px 12px; outline: none; font-size: 12.5px;
  transition: 150ms ease;
}
.input { height: 38px; }
.textarea { min-height: 260px; resize: vertical; line-height: 1.55; font-family: var(--font-mono); font-size: 11.5px; }
.input:focus, .textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(216, 27, 42, 0.09); }
.textarea.short { min-height: 150px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.char-count { text-align: right; font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--line); }
.switch-row:first-of-type { border-top: none; padding-top: 0; }
.switch-row .label { font-size: 12.5px; color: var(--text-soft); }
.switch-row .hint { font-size: 10.5px; color: var(--muted-2); margin-top: 2px; }
.switch {
  position: relative; width: 40px; height: 22px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line); flex: 0 0 auto;
  transition: 160ms ease;
}
.switch::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #d4d4d4; top: 2px; left: 2px; transition: 160ms ease; }
.switch.on { background: rgba(216, 27, 42, 0.55); border-color: var(--accent-line); }
.switch.on::after { left: 20px; background: #ffffff; }
.settings-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.md-preview { margin-top: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #101010; max-height: 360px; overflow: auto; }
.md-preview .md { font-size: 12px; }

/* ------------------------------------------------------------- markdown */

.md { line-height: 1.65; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 20px 0 8px; line-height: 1.25; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 14.5px; }
.md h4 { font-size: 13px; }
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 3px 0; }
.md strong { color: #fff; font-weight: 700; }
.md em { color: var(--text-soft); }
.md code { font-family: var(--font-mono); font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); color: #ffb3b8; }
.md pre { margin: 0 0 12px; padding: 13px; border-radius: 10px; background: #0a0a0a; border: 1px solid var(--line); overflow: auto; }
.md pre code { padding: 0; background: transparent; color: #f5f5f5; font-size: 11.5px; line-height: 1.55; }
.md blockquote { margin: 0 0 10px; padding: 8px 12px; border-left: 2px solid var(--accent); background: rgba(216, 27, 42, 0.06); color: var(--muted); }
.md table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.md th { background: rgba(255, 255, 255, 0.045); color: var(--text-soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.md a { color: var(--accent-2); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* ------------------------------------------------------------- drawer / chat */

.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  height: 46px; padding: 0 17px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff; font-weight: 700; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  box-shadow: 0 12px 34px rgba(216, 27, 42, 0.3);
  transition: 180ms ease;
}
.fab:hover { transform: translateY(-2px); background: var(--accent-hover); box-shadow: 0 16px 44px rgba(216, 27, 42, 0.4); }
.fab svg { width: 18px; height: 18px; }
.fab.hidden { opacity: 0; pointer-events: none; transform: translateY(10px); }

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: 200ms ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 71;
  width: min(470px, 100vw);
  display: flex; flex-direction: column;
  background:
    radial-gradient(600px 300px at 100% 0%, rgba(216, 27, 42, 0.12), transparent 60%),
    #111111;
  border-left: 1px solid var(--line-strong);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 16px 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 11px; }
.drawer-head .ai-avatar {
  width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(216, 27, 42, 0.1);
  border: 1px solid var(--accent-line); color: var(--accent-2);
}
.drawer-head .ai-avatar svg { width: 18px; height: 18px; }
.drawer-head .t { flex: 1; min-width: 0; }
.drawer-head .t strong { display: block; font-family: var(--font-display); font-size: 14px; }
.drawer-head .t span { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-actions { display: flex; gap: 5px; }

.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-welcome { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #171717; }
.chat-welcome h4 { margin: 0 0 5px; font-family: var(--font-display); font-size: 14px; }
.chat-welcome p { margin: 0; color: var(--muted); font-size: 12px; }
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.suggestion {
  text-align: left; padding: 9px 11px; border-radius: 6px;
  border: 1px solid var(--line); background: #1a1a1a;
  color: var(--text-soft); font-size: 11.5px; transition: 150ms ease;
}
.suggestion:hover { border-color: var(--accent-line); background: var(--accent-soft); }

.chat-msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: 12.5px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-msg.user { align-self: flex-end; background: rgba(216, 27, 42, 0.1); border: 1px solid rgba(216, 27, 42, 0.25); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-msg.assistant { align-self: flex-start; background: #1a1a1a; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg .md { font-size: 12.5px; }
.chat-msg .md h1, .chat-msg .md h2, .chat-msg .md h3 { font-size: 14px; margin: 12px 0 6px; }
.chat-msg .md p { margin-bottom: 8px; }
.chat-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chat-tools { margin-top: 9px; border-top: 1px solid rgba(255, 255, 255, 0.06); padding-top: 7px; }
.chat-tools summary { cursor: pointer; color: var(--muted); font-size: 10.5px; }
.chat-tools pre { margin: 6px 0 0; padding: 8px; border-radius: 7px; background: #0a0a0a; border: 1px solid var(--line); font-family: var(--font-mono); font-size: 10px; color: #ffb3b8; overflow: auto; max-height: 140px; white-space: pre-wrap; }
.chat-save { margin-top: 8px; }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); animation: typing 1s infinite; }
.typing span:nth-child(2) { animation-delay: 0.14s; }
.typing span:nth-child(3) { animation-delay: 0.28s; }
@keyframes typing { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.chat-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); background: #111111; }
.chat-input-wrap { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: #101010; padding: 7px 7px 7px 11px; transition: 150ms ease; }
.chat-input-wrap:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(216, 27, 42, 0.09); }
.chat-input { flex: 1; resize: none; border: none; background: transparent; outline: none; color: var(--text); font-size: 12.5px; line-height: 1.5; max-height: 120px; min-height: 24px; padding: 4px 0; }
.chat-send { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 6px; border: none; background: var(--accent); color: #ffffff; display: grid; place-items: center; }
.chat-send:hover { background: var(--accent-2); }
.chat-send:disabled { opacity: 0.4; }
.chat-send svg { width: 16px; height: 16px; }
.chat-hint { font-size: 9.5px; color: var(--muted-2); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }
.chat-context { display: inline-flex; align-items: center; gap: 5px; }

/* ------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(5px); display: grid; place-items: center; padding: 22px;
  opacity: 0; pointer-events: none; transition: 180ms ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(760px, 100%); max-height: min(86dvh, 900px);
  display: flex; flex-direction: column;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: #151515;
  box-shadow: var(--shadow); transform: translateY(10px) scale(0.99); transition: 180ms ease;
}
.modal-backdrop.open .modal { transform: none; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }
.modal-body { padding: 19px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 19px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- toast */

.toasts { position: fixed; top: calc(var(--nav-h) + 14px); right: 18px; z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: #1a1a1a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  animation: toastIn 220ms cubic-bezier(0.22, 1, 0.36, 1);
  font-size: 12px; color: var(--text-soft);
}
.toast.success { border-color: rgba(16, 185, 129, 0.35); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-top: 5px; flex: 0 0 auto; }
.toast.error .dot { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- misc */

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-line { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11.5px; }
.fade-up { animation: fadeUp 260ms ease both; }
@keyframes fadeUp { from { transform: translateY(6px); } to { transform: none; } }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1120px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .conversation { max-height: 56dvh; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .topbar { gap: 14px; padding: 0 14px; }
  .brand-text span { display: none; }
  .status-pill { display: none; }
  .auth-pill { display: none; }
  .company-select { max-width: 130px; }
  .table-head { display: none; }
  .contact-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px; height: auto; padding: 13px 14px;
  }
  .contact-row .col-origem, .contact-row .col-msgs { display: none; }
  .contact-row .col-last { display: none; }
  .contact-row .col-tempo { text-align: right; }
  .contact-row .chev { display: none; }
  .contact-row .col-nota { display: none; }
  .main-inner { padding: 20px 16px 100px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { align-items: flex-start; }
}

@media (max-width: 620px) {
  .topbar { height: 60px; }
  :root { --nav-h: 60px; }
  .tabs { gap: 2px; }
  .tab { padding: 0 10px; font-size: 12px; }
  .tab span { display: none; }
  .tab.active span { display: inline; }
  .tab svg { display: block; }
  .tab.active::after { bottom: -11px; }
  .brand-text strong { font-size: 14px; }
  .company-select { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 22px; }
  .detail-head { padding: 15px; }
  .detail-person h1 { font-size: 20px; }
  .detail-actions { width: 100%; }
  .detail-actions .btn { flex: 1; }
  .metric-grid { gap: 8px; }
  .kv-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 9px; }
  .search { flex-basis: 100%; }
  .fab { right: 14px; bottom: 14px; }
  .drawer { width: 100vw; }
  .toasts { top: 70px; right: 10px; }
  .modal-body { padding: 15px; }
  .conversation { padding: 13px; max-height: 52dvh; }
  .msg { max-width: 88%; }
}
