:root {
  --accent: #5DB8FF;
  --accent-ink: #08131E;
  --ink: #F2F2F2;
  --white: #FFFFFF;
  --muted: #A9AEB8;
  --bg: #141414;
  --panel: #1E1E1E;
  --card: #232323;
  --line: #3A3A3A;
  --line-strong: #50555F;
  --col: rgba(12, 12, 12, 0.78);
  --good: #6FE0A0;
  --bad: #FFA79B;
  --font: 'Montserrat', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image: url(/textura.jpg);
  background-size: 1024px 1024px;
  min-height: 100vh;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.28em; color: var(--muted); text-transform: uppercase; }
.glow { font-size: 34px; font-weight: 900; letter-spacing: -0.01em; color: var(--white); text-shadow: 0 0 24px rgba(93, 184, 255, 0.53); }

.page { padding: 32px 40px 40px; display: flex; flex-direction: column; gap: 24px; min-height: 100vh; }

/* Cabeçalho */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 20px; }
.brand-logo { width: 88px; height: 88px; object-fit: contain; }
.brand .muted { margin-top: 4px; font-size: 14px; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.btn { min-height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 800; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.glowbtn { box-shadow: 0 0 22px rgba(93, 184, 255, 0.53); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); font-weight: 700; }
.btn.danger { background: transparent; color: var(--bad); border-color: #7A3A33; font-weight: 700; }

/* Métricas */
.scope { font-size: 13px; color: var(--muted); }
.scope strong { color: var(--white); font-weight: 800; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: -12px; }
.metric { padding: 16px 18px; background: rgba(30, 30, 30, 0.92); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 4px; }
.metric .label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.metric .num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--white); }
.metric .sub { font-size: 13px; color: var(--muted); }
.metric.accent .num { color: var(--accent); }
.metric.good .num { color: var(--good); }

/* Resumo por comercial (administrador) */
.team { background: rgba(30, 30, 30, 0.92); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-top: -8px; }
.team .section-title { margin-bottom: 8px; }
.table-wrap { overflow-x: auto; }
.team table { width: 100%; border-collapse: collapse; font-size: 14px; }
.team th, .team td { text-align: left; padding: 10px 12px; border-top: 1px solid #333; white-space: nowrap; }
.team thead th { border-top: 0; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.team tbody th { font-weight: 700; color: var(--white); }
.team td { color: var(--ink); }

/* Filtros */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.search { flex: 1 1 240px; max-width: 320px; }
label { font-size: 12px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  min-height: 44px; padding: 0 12px; background: #141414; color: var(--white);
  border: 1px solid var(--line-strong); border-radius: 8px;
}
.search input { background: var(--panel); padding: 0 14px; border-radius: 10px; }
textarea { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.4; }
.fgroups { display: contents; }
.fgroup { display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 10px; font-weight: 700; font-size: 13px; background: rgba(30, 30, 30, 0.92); color: var(--ink); border: 1px solid var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--white); color: #141414; border-color: var(--white); }

/* Quadro */
.board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.col { flex: 0 0 304px; padding: 12px; background: var(--col); border: 1px solid #2E2E2E; border-radius: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.col.over { border-color: var(--accent); background: rgba(20, 30, 40, 0.85); }
.col-head { padding: 4px 4px 0; display: flex; flex-direction: column; gap: 4px; }
.col-title { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, #999); }
.col-title h2 { flex: 1; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--white); }
.count { font-size: 12px; font-weight: 700; background: #2B2B2B; border-radius: 999px; padding: 2px 10px; }
.col-total { font-size: 13px; font-weight: 600; color: var(--muted); }
.empty { padding: 24px 12px; text-align: center; font-size: 13px; color: var(--muted); border: 1px dashed #4A4A4A; border-radius: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; }
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: 0.4; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card h3 { font-size: 15px; font-weight: 700; color: var(--white); overflow-wrap: anywhere; }
.card .company { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.temp { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.temp-Quente { background: #4A2019; color: #FFB8AB; }
.temp-Morno { background: #443210; color: #FFD58A; }
.temp-Frio { background: #15304F; color: #A9D4FF; }
.value { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; color: var(--white); }
.meta { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: #C9CDD5; }
.meta li { display: flex; align-items: flex-start; gap: 6px; overflow-wrap: anywhere; }
.meta svg { flex: 0 0 auto; margin-top: 1px; }
.wa { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 8px; background: rgba(23, 48, 35, 0.25); border: 1px solid #2F6B4A; color: #8CF0B7; font-size: 13px; font-weight: 700; text-decoration: none; }
.actions { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid #353535; }
.actions button { flex: 1 1 0; min-height: 44px; border-radius: 8px; font-size: 13px; font-weight: 700; background: transparent; border: 1px solid var(--line-strong); color: var(--ink); }
.actions .fwd { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 800; }
.actions .lost { flex: 0 0 auto; padding: 0 12px; border-color: #7A3A33; color: var(--bad); }

/* Gaveta do lead */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: 11; background: #191919; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.drawer-head { padding: 20px 24px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 20px; font-weight: 800; color: var(--white); overflow-wrap: anywhere; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; font-size: 22px; line-height: 1; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2 .wide { grid-column: 1 / -1; }
.section-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 10px; }

.timeline { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding: 4px 2px 8px; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: 86%; }
.msg .bubble { padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .stamp { font-size: 11px; color: var(--muted); }
.msg.in { align-self: flex-start; }
.msg.in .bubble { background: #2E2E2E; border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .bubble { background: #17334D; border: 1px solid #2A5A85; border-bottom-right-radius: 4px; }
.msg.note { align-self: stretch; max-width: none; }
.msg.note .bubble { background: #3A311A; border: 1px dashed #8A7436; color: #FFE9AE; }
.msg.sys { align-self: center; max-width: 100%; text-align: center; font-size: 11px; color: var(--muted); }
.timeline-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 16px 0; }

.composer { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.kinds label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); font-size: 13px; cursor: pointer; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds input:checked + span { color: var(--accent); font-weight: 800; }
.kinds label:has(input:checked) { border-color: var(--accent); }
.kinds label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 12px; color: var(--muted); }

/* Diálogo e login */
.dialog { width: min(640px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: #191919; color: var(--ink); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-form h2 { font-size: 20px; font-weight: 800; color: var(--white); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.form-error { color: var(--bad); font-size: 13px; font-weight: 600; }

.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.form-ok { color: var(--good); font-size: 13px; font-weight: 600; }

.users-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.user-row.off { opacity: 0.65; }
.user-info { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-info strong { color: var(--white); font-size: 15px; overflow-wrap: anywhere; }
.user-info span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #2B2B2B; color: var(--ink); }
.badge.admin { background: #17334D; color: #A9D4FF; }
.badge.off { background: #4A2019; color: #FFB8AB; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.user-actions button { min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 700; background: transparent; border: 1px solid var(--line-strong); color: var(--ink); }
.user-actions button.warn { border-color: #7A3A33; color: var(--bad); }
.user-actions button:disabled { opacity: 0.4; cursor: not-allowed; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(380px, 100%); padding: 32px 28px; background: rgba(25, 25, 25, 0.94); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 8px; }
.login-card label { margin-top: 8px; }
.login-card .btn { margin-top: 12px; }
.login-logo { width: 88px; height: 88px; object-fit: contain; margin-bottom: 4px; }

@media (max-width: 900px) {
  .page { padding: 24px 16px 32px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .col { flex-basis: 86vw; }
  .drawer-body { padding: 16px; }
  .brand-logo { width: 64px; height: 64px; }
  .glow { font-size: 28px; }
}
