:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e2e6ea;
  --text: #1c2630;
  --muted: #64717e;
  --primary: #1f5f8b;
  --primary-soft: #e6f0f7;
  --success: #1e7b4f;
  --success-soft: #e3f4ea;
  --warning: #9a6200;
  --warning-soft: #fdf1dc;
  --danger: #b4322b;
  --danger-soft: #fbe7e5;
  --wa: #1c8f5a;
  --wa-bubble: #dcf5e6;
  --sidebar: #16324a;
  --sidebar-text: #c6d5e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .05);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 620; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 620; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15px; padding: 4px 10px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: #2f7bb0; display: grid; place-items: center; font-weight: 800; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text); }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.ativo { background: rgba(255,255,255,.12); color: #fff; }
.nav .badge { margin-left: auto; background: #e04b3c; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.nav svg { width: 17px; height: 17px; flex: none; }
.sidebar .rodape { margin-top: auto; padding: 12px 10px 0; font-size: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar .rodape a { color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .espaco { flex: 1; }
.conteudo { padding: 22px 24px 40px; max-width: 1400px; width: 100%; }
.cabecalho { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.cabecalho .espaco { flex: 1; }
.btn.menu-btn { display: none; }
.btn svg { width: 18px; height: 18px; }

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.kpi:hover { border-color: #c7d1da; }
.kpi .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.alerta .v { color: var(--danger); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primario { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primario:hover { background: #194f74; }
.btn.verde { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.perigo { color: var(--danger); }
.btn.peq { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ponto { font-size: 15px; padding: 12px 20px; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3e0; outline-offset: -1px; border-color: #9cc3e0; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 550; }
.campo { margin-bottom: 12px; }
.linha { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros > * { width: auto; min-width: 140px; }
.filtros input[type=search] { min-width: 220px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.clicavel { cursor: pointer; }
tr.clicavel:hover td { background: var(--surface-2); }
.tabela { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
.tabela td.r, .tabela th.r { text-align: right; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.tag.aberta { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.tag.em_andamento { background: #efe8fb; color: #5b3b99; border-color: transparent; }
.tag.aguardando_cliente, .tag.aguardando { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tag.concluida, .tag.valida, .tag.em_atendimento { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag.cancelada, .tag.recusada, .tag.encerrada { background: #eef0f2; color: #7a8591; border-color: transparent; }
.tag.pendente { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tag.urgente { background: var(--danger); color: #fff; border-color: transparent; }
.tag.alta { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.prazo.atrasado { color: var(--danger); font-weight: 600; }
.prazo.hoje { color: var(--warning); font-weight: 600; }

.vazio { text-align: center; padding: 36px; color: var(--muted); }
.barra { height: 8px; background: #e8edf1; border-radius: 4px; overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.lista-barras .item { display: grid; grid-template-columns: 180px 1fr 70px; gap: 10px; align-items: center; padding: 5px 0; }
.lista-barras .item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.abas button { border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.abas button.ativa { color: var(--primary); border-bottom-color: var(--primary); }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.coluna { background: #eaeef2; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.coluna h3 { display: flex; justify-content: space-between; font-size: 13px; }
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.cartao:hover { border-color: #b8c4cf; }
.cartao .t { font-weight: 580; margin-bottom: 4px; }
.coluna.sobre { outline: 2px dashed var(--primary); }

/* Modal / gaveta */
.fundo { position: fixed; inset: 0; background: rgba(15, 25, 35, .4); z-index: 20; display: flex; justify-content: flex-end; }
.fundo.centro { align-items: center; justify-content: center; padding: 16px; }
.gaveta { background: var(--surface); width: min(640px, 100%); height: 100%; overflow-y: auto; padding: 20px 22px; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.modal { background: var(--surface); width: min(520px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 12px; padding: 20px 22px; }
.modal-topo { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-topo h2 { margin: 0; flex: 1; }
.fechar { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.historico { border-left: 2px solid var(--border); padding-left: 14px; margin-top: 8px; }
.historico .ev { margin-bottom: 12px; }
.historico .ev.alteracao, .historico .ev.sistema { color: var(--muted); font-size: 12.5px; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2630; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.erro { background: var(--danger); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #16324a, #1f5f8b); }
.login .card { width: min(380px, 100%); padding: 28px; }

/* Atendimento */
.atendimento { display: grid; grid-template-columns: 320px 1fr 290px; height: calc(100vh - 57px); background: var(--surface); }
.conv-lista { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.conv-lista .topo { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.conv-lista .itens { overflow-y: auto; flex: 1; }
.conv { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.conv:hover { background: var(--surface-2); }
.conv.ativa { background: var(--primary-soft); }
.conv .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .p { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .h { font-size: 11.5px; color: var(--muted); text-align: right; }
.conv .nl { background: var(--wa); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; justify-self: end; line-height: 18px; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #efeae2; }
.chat .topo { background: var(--surface); padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 6px; }
.bolha { max-width: 72%; padding: 7px 10px 5px; border-radius: 8px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; }
.bolha.out { align-self: flex-end; background: var(--wa-bubble); }
.bolha.nota { align-self: center; background: #fff6d6; font-size: 12.5px; color: #6b5a1f; max-width: 85%; }
.bolha .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bolha.falha { border: 1px solid var(--danger); }
.dia-sep { align-self: center; background: #fff; font-size: 11.5px; padding: 2px 10px; border-radius: 6px; color: var(--muted); margin: 6px 0; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px; }
.composer .linha-c { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; }
.composer.nota textarea { background: #fffbea; }
.sugestoes { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; max-height: 180px; overflow-y: auto; }
.sugestoes div { padding: 7px 10px; cursor: pointer; }
.sugestoes div:hover, .sugestoes div.sel { background: var(--primary-soft); }
.aviso { background: var(--warning-soft); color: var(--warning); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.aviso.info { background: var(--primary-soft); color: var(--primary); }
.painel { border-left: 1px solid var(--border); padding: 14px; overflow-y: auto; }
.painel .bloco { margin-bottom: 18px; }
.chat-vazio { flex: 1; display: grid; place-items: center; color: var(--muted); }

/* Ponto */
.relogio { font-size: 40px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.marcas { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.marca { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; text-align: center; min-width: 92px; }
.marca b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.marca.pendente { border-style: dashed; border-color: var(--warning); }
.situacao { display: inline-flex; align-items: center; gap: 6px; }
.situacao::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #aab4be; }
.situacao.trabalhando::before { background: #22a060; }
.situacao.intervalo::before { background: #e0a100; }
tr.fds td { color: var(--muted); background: #fafbfc; }
.saldo-pos { color: var(--success); }
.saldo-neg { color: var(--danger); }

.cronometro { display: inline-flex; align-items: center; gap: 8px; background: var(--success-soft); color: var(--success); border-radius: 20px; padding: 4px 6px 4px 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cronometro .btn { padding: 2px 8px; }

@media (max-width: 1100px) {
  .atendimento { grid-template-columns: 280px 1fr; }
  .painel { display: none; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 240px; z-index: 30; transition: left .2s; }
  .sidebar.aberta { left: 0; }
  .btn.menu-btn { display: inline-flex; }
  .card { overflow-x: auto; }
  .conteudo { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .atendimento { grid-template-columns: 1fr; }
  .atendimento.com-chat .conv-lista { display: none; }
  .atendimento:not(.com-chat) .chat { display: none; }
  .kanban { grid-template-columns: repeat(4, 260px); }
  .lista-barras .item { grid-template-columns: 110px 1fr 60px; }
  .esconder-mobile { display: none; }
}

/* Situação do cliente (ativo/inativo) */
.sit { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap; font-family: inherit; line-height: 1.4; }
.sit::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sit.ativo { background: var(--success-soft); color: var(--success); }
.sit.inativo { background: var(--danger-soft); color: var(--danger); }
button.sit { cursor: pointer; }
button.sit:hover { border-color: currentColor; }
tr.inativo td { color: var(--muted); }

/* Etapas da tarefa (execução → revisão → entrega) */
.etapas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.etapa { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.etapa:hover { border-color: var(--primary); }
.etapa .n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.etapa.feita { background: var(--success-soft); border-color: transparent; }
.etapa.feita .n { background: var(--success); color: #fff; border-color: var(--success); }
.etapa .small { color: var(--muted); }
@media (max-width: 560px) { .etapas { grid-template-columns: 1fr; } }
.etapas-mini { display: inline-flex; gap: 3px; vertical-align: middle; }
.etapas-mini i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-block; }
.etapas-mini i.ok { background: var(--success); border-color: var(--success); }

/* Cronograma (grade atividade × empresa) */
.crono-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.crono { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.crono th, .crono td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; }
.crono thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; vertical-align: bottom; }
.crono thead th.cli { writing-mode: vertical-rl; transform: rotate(180deg); padding: 8px 4px; max-height: 170px; white-space: nowrap; text-align: left; min-width: 34px; font-weight: 500; }
.crono thead th.grp { writing-mode: horizontal-tb; transform: none; text-align: center; padding: 4px 6px; font-size: 11px; color: var(--muted); }
.crono .ativ { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 280px; max-width: 320px; padding: 6px 10px; text-align: left; font-weight: 400; }
.crono thead .ativ { z-index: 3; background: var(--surface-2); }
.crono .ativ b { font-weight: 600; }
.crono .est { padding: 4px 8px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.crono td.c { width: 34px; min-width: 34px; height: 30px; text-align: center; cursor: pointer; font-size: 13px; position: relative; }
.crono td.c:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.crono td.c.sel { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--primary-soft) !important; }
.crono td.vazio { background: repeating-linear-gradient(45deg, transparent, transparent 4px, var(--surface-2) 4px, var(--surface-2) 6px); cursor: default; }
.crono td.s-pend { background: var(--surface); }
.crono td.s-atr { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.crono td.s-exec { background: #fff4d6; color: #8a5a00; }
.crono td.s-rev { background: #e7eefc; color: #2a4f9e; }
.crono td.s-ok { background: var(--success-soft); color: var(--success); font-weight: 700; }
.crono td.s-na { background: #eef0f2; color: #7a8591; }
.crono td.s-agu { background: #efe8fb; color: #5b3b99; }
.crono td.c .com { position: absolute; top: 1px; right: 2px; width: 0; height: 0; border-left: 6px solid transparent; border-top: 6px solid #d18b00; }
.legenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }
.legenda span { display: inline-flex; align-items: center; gap: 5px; }
.legenda i { width: 16px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--border); text-align: center; font-style: normal; font-size: 10px; line-height: 12px; }
.barra { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.barra > i { display: block; height: 100%; background: var(--success); }
.lote-barra { position: sticky; bottom: 0; background: var(--text); color: #fff; padding: 8px 12px; border-radius: var(--radius); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.lote-barra .btn { background: #fff; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .g4 { grid-template-columns: 1fr 1fr; } }
