:root {
  --bg: #f4f6fa;
  --card: #fff;
  --borda: #e3e7ee;
  --texto: #1d2433;
  --muted: #6b7486;
  --primaria: #2457d6;
  --primaria-escura: #1b45ad;
  --sidebar: #141b2d;
  --sidebar-texto: #c3cad8;
  --sucesso: #1f9d55;
  --perigo: #d33b3b;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--texto); font-size: 14px; line-height: 1.5; }
a { color: var(--primaria); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 18px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.pequeno { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.direita { text-align: right; }
.centro { text-align: center; }
.mt { margin-top: 1.4em; }
.mt-p { margin-top: .5em; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar); color: var(--sidebar-texto); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.marca { display: flex; gap: 10px; align-items: center; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.marca-icone { width: 36px; height: 36px; display: grid; place-items: center; background: var(--primaria); color: #fff; border-radius: 9px; font-size: 18px; }
.marca strong { color: #fff; display: block; font-size: 14px; }
.marca small { font-size: 11px; opacity: .7; }
.sidebar nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar a { color: var(--sidebar-texto); padding: 9px 12px; border-radius: 8px; display: block; }
.sidebar a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar a.ativo { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.nav-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .5; padding: 16px 12px 6px; }
.sidebar-rodape { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.07); display: flex; justify-content: space-between; align-items: center; }
.sidebar-rodape .link { color: var(--sidebar-texto); }
.conteudo { flex: 1; padding: 20px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; min-height: 36px; }
.menu-btn { display: none; background: none; border: 1px solid var(--borda); border-radius: 8px; font-size: 18px; padding: 4px 10px; cursor: pointer; }
.conteudo-solo { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 18px 20px; box-shadow: var(--sombra); margin-bottom: 16px; }
.card.sem-padding { padding: 0; overflow-x: auto; }
.card-titulo-pad { padding: 16px 20px 0; }
.card.estreito { max-width: 720px; }
.card-topo { display: flex; justify-content: space-between; align-items: baseline; }
.vazio { text-align: center; padding: 40px 20px; }
.barra-acoes { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.barra-acoes form { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--borda); background: #fff; color: var(--texto); padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #f0f2f6; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primario { background: var(--primaria); border-color: var(--primaria); color: #fff; }
.btn-primario:hover { background: var(--primaria-escura); }
.btn-sucesso { background: var(--sucesso); border-color: var(--sucesso); color: #fff; }
.btn-sucesso:hover { background: #18834a; }
.btn-perigo { color: var(--perigo); border-color: #f1c4c4; }
.btn-perigo:hover { background: #fdf0f0; }
.btn-bloco { width: 100%; }
.btn-mini { padding: 4px 9px; font-size: 12px; }
button.link { background: none; border: none; color: var(--primaria); cursor: pointer; padding: 0; font-size: inherit; }
.link { font-size: 13px; }

.alerta { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alerta-sucesso { background: #eaf7ef; border-color: #bfe5cd; color: #136b39; }
.alerta-erro { background: #fdeeee; border-color: #f3c3c3; color: #a32626; }
.alerta-aviso { background: #fff7e6; border-color: #f5dca6; color: #8a5a00; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; margin: 1px 0; }
.st-aberto { background: #e6efff; color: #1d4fc4; }
.st-em_andamento { background: #fff3d6; color: #8a5a00; }
.st-aguardando { background: #f2e8ff; color: #6a2fc2; }
.st-resolvido { background: #e3f6ea; color: #157a40; }
.st-fechado { background: #eceef2; color: #5a6274; }
.pr-baixa { background: #eef6ee; color: #3d7a3d; }
.pr-media { background: #fff8db; color: #7d6500; }
.pr-alta { background: #ffeadb; color: #b4530b; }
.pr-urgente { background: #ffe1e1; color: #c12121; }
.tag { font-size: 11px; background: #eef1f6; color: var(--muted); padding: 1px 7px; border-radius: 5px; }
.tag-interna { background: #fff3d6; color: #8a5a00; }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.inline { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #cfd5df; border-radius: 8px; background: #fff; color: var(--texto); width: 100%; }
input[type=checkbox] { width: auto; }
label.inline select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(36,87,214,.25); border-color: var(--primaria); }
input:disabled { background: #f3f5f8; color: var(--muted); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.acoes-esquerda { justify-content: flex-start; gap: 16px; }
.acoes-esquerda .btn-primario { margin-left: auto; }
.input-grupo { display: flex; gap: 6px; }

.upload-area { position: relative; border: 2px dashed #cfd5df; border-radius: 10px; padding: 16px; text-align: center; background: #fafbfd; transition: .15s; }
.upload-area.arrastando { border-color: var(--primaria); background: #eef3ff; }
.upload-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload-texto { pointer-events: none; font-size: 13px; }
.upload-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; justify-content: center; position: relative; z-index: 2; }
.upload-previews:empty { display: none; }
.preview { position: relative; width: 96px; text-align: center; }
.preview img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--borda); display: block; }
.preview .preview-arq { display: grid; place-items: center; width: 96px; height: 72px; font-size: 28px; background: #fff; border: 1px solid var(--borda); border-radius: 6px; }
.preview small { display: block; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview button { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--perigo); color: #fff; cursor: pointer; line-height: 1; }

/* ---------- Tabelas ---------- */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--borda); background: #fafbfd; }
.tabela td { padding: 11px 14px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.tabela tr:last-child td { border-bottom: none; }
.tabela.compacta td, .tabela.compacta th { padding: 7px 8px; background: none; }
.card .tabela:not(.compacta) td:first-child { padding-left: 20px; }
.clicavel { cursor: pointer; }
.clicavel:hover td { background: #f7f9fd; }
tr.inativo td { opacity: .5; }
.acoes-linha { display: flex; gap: 6px; flex-wrap: wrap; }
.acoes-linha form { margin: 0; }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filtros input[type=search] { flex: 1; min-width: 200px; }
.filtros select { width: auto; }
.paginacao { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 10px; }

/* ---------- Dashboard ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px 18px; box-shadow: var(--sombra); color: var(--texto); display: flex; flex-direction: column; }
a.kpi:hover { text-decoration: none; border-color: #c5cfe0; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi strong { font-size: 32px; line-height: 1.2; margin: 4px 0 2px; }
.kpi small { font-size: 12px; color: var(--muted); }
.kpi.destaque { background: var(--primaria); border-color: var(--primaria); color: #fff; }
.kpi.destaque span, .kpi.destaque small { color: rgba(255,255,255,.8); }
.kpi.alerta-kpi strong { color: var(--perigo); }
.grid-dash { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.grid-dash > .card { margin-bottom: 16px; }

.barras { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 18px; }
.barra-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.barra { width: 100%; max-width: 34px; background: var(--primaria); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.barra-col:hover .barra { opacity: 1; }
.barra-valor { font-size: 11px; color: var(--muted); }
.barra-label { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.lista-num { list-style: none; padding: 0; margin: 0; }
.lista-num li { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dashed #eceff4; }
.lista-num li:last-child { border-bottom: none; }
.hbarra { margin-bottom: 10px; }
.hbarra-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.hbarra-fundo { background: #eef1f6; border-radius: 99px; height: 7px; overflow: hidden; }
.hbarra-fundo div { background: var(--primaria); height: 100%; border-radius: 99px; }

/* ---------- Detalhe do chamado ---------- */
.detalhe { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.chamado-cabecalho { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid #eef0f4; }
.chamado-cabecalho h2 { margin: 2px 0 4px; font-size: 20px; }
.texto { white-space: pre-wrap; word-wrap: break-word; }
.anexos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.anexo-img img { max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--borda); display: block; }
.anexo-img:hover img { border-color: var(--primaria); }
.anexo-arq { border: 1px solid var(--borda); border-radius: 8px; padding: 8px 12px; background: #fafbfd; font-size: 13px; }
.timeline { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.msg { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 16px; max-width: 88%; box-shadow: var(--sombra); }
.msg-ti { align-self: flex-end; background: #f0f5ff; border-color: #cfdcfb; }
.msg-cliente { align-self: flex-start; }
.msg-interna { background: #fffaeb; border-color: #f2dfa6; border-style: dashed; }
.msg-topo { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.evento { font-size: 12px; color: var(--muted); text-align: center; }
.info { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-word; }
.atalhos { margin-top: 10px; }

/* ---------- Login ---------- */
.login-box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--borda); border-radius: 14px; padding: 32px 28px; box-shadow: 0 10px 30px rgba(16,24,40,.08); text-align: center; }
.login-box .form { text-align: left; margin-top: 18px; }
.login-marca { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--primaria); color: #fff; border-radius: 14px; font-size: 26px; }
.login-box h2 { margin-bottom: 4px; }

/* ---------- Responsivo ---------- */
@media (max-width: 980px) {
  .grid-dash, .detalhe { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .sidebar.aberto { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: block; }
  .conteudo { padding: 14px 14px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .tabela th, .tabela td { padding: 9px 10px; }
  .chamado-cabecalho { flex-direction: column; }
}
