/* =====================================================================
   VisionsWorkspace — Design System (admin moderno)
   Inspirado no layout de referência; paleta azul (estilo MargemLucro).
   ===================================================================== */

:root {
    --primary:        #018b98;   /* teal (cor oficial do sistema) */
    --primary-light:  #0aa5b3;
    --primary-dark:   #016d77;
    --primary-50:     #e6f4f5;
    --success:        #018b98;
    --success-dark:   #016d77;
    --success-50:     #e6f4f5;
    --warning:        #ca8a04;
    --danger:         #dc2626;
    --info:           #0891b2;

    --bg:             #f8fafc;
    --sidebar-bg:     #ffffff;
    --card-bg:        #ffffff;
    --border:         #e2e8f0;
    --text:           #1e293b;
    --muted:          #64748b;

    --sidebar-width:     240px;
    --sidebar-collapsed: 60px;
    --header-height:     60px;
    --radius:            10px;
    --radius-sm:         7px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    --font: 'Segoe UI', system-ui, -apple-system, 'Inter', sans-serif;
    --font-mono: 'DM Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 12px; /* densidade ultra-compacta (era 14px) */
    line-height: 1.5;
}
a { color: var(--primary); }

/* ───────────────────────── SIDEBAR ───────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    z-index: 100;
    transition: width .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    min-height: var(--header-height);
    flex-shrink: 0;
}
.sidebar-logo img { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.sidebar-logo .logo-text {
    font-weight: 700; font-size: 13px; color: var(--text);
    letter-spacing: -.01em; transition: opacity .2s;
}
.sidebar-logo .logo-text span { color: var(--primary); }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

.sidebar-toggle {
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; color: var(--muted);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px; flex-shrink: 0;
    margin: 12px 12px 0 auto;
    transition: background .15s, transform .25s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; overflow-x: hidden; }
.nav-section {
    padding: 11px 16px 4px; font-size: 9.5px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
    white-space: nowrap; overflow: hidden; transition: opacity .15s, height .2s;
}
.sidebar.collapsed .nav-section { opacity: 0; height: 0; padding: 0; }

.nav-item, .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; margin: 1px 8px; border-radius: 7px;
    color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
    transition: background .15s, color .15s, padding .25s;
    white-space: nowrap; overflow: hidden; position: relative;
}
.sidebar.collapsed .nav-item { padding: 9px 0; margin: 1px 4px; justify-content: center; }
.nav-item:hover, .nav-link:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active, .nav-link.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nav-item .fa { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }
.nav-item .nav-label { transition: opacity .15s, width .15s; overflow: hidden; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }
.sidebar.collapsed .nav-item:hover::after {
    content: attr(data-label); position: absolute; left: 64px; top: 50%;
    transform: translateY(-50%); background: var(--text); color: #fff;
    padding: 4px 10px; border-radius: 6px; font-size: 10px; font-weight: 500;
    white-space: nowrap; pointer-events: none; z-index: 200; box-shadow: var(--shadow-md);
}

.sidebar-footer { padding: 12px 14px; border-top: 1px solid var(--border); overflow: hidden; }
.sidebar-footer .user-name {
    display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12px;
    color: var(--text); text-decoration: none; white-space: nowrap;
}
.sidebar-footer .user-name i { color: var(--muted); }
.logout-form { margin: 0; }
.logout-btn, .sidebar-footer .btn-outline {
    margin-top: 10px; width: 100%; justify-content: center;
}
.sidebar.collapsed .footer-text { opacity: 0; height: 0; }

/* ───────────────────────── MAIN ───────────────────────── */
.main-wrap {
    margin-left: var(--sidebar-width); flex: 1;
    display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-left .25s cubic-bezier(.4,0,.2,1); min-width: 0;
}
.main-wrap.collapsed { margin-left: var(--sidebar-collapsed); }

.topbar {
    height: var(--header-height); background: var(--card-bg);
    border-bottom: 1px solid var(--border); display: flex; align-items: center;
    justify-content: space-between; padding: 0 24px; position: sticky; top: 0;
    z-index: 50; box-shadow: var(--shadow);
}
.topbar-title { font-size: 13.5px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.topbar .menu-btn { background: none; border: none; cursor: pointer; padding: 4px; color: var(--muted); font-size: 17px; }

.content, .main-content { padding: 24px; flex: 1; min-width: 0; }

/* ───────────────────────── PAGE HEADER ───────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title, .page-header h1 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle, .page-header p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.page-header-meta { color: var(--muted); font-size: 11px; }

/* ───────────────────────── CARDS ───────────────────────── */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h5 { font-size: 13px; font-weight: 600; }
.card-body { padding: 20px; }
.cards-grid, .cadastros-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 16px; }

.cadastro-card, .connection-card {
    display: block; padding: 18px 20px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--card-bg); text-decoration: none;
    color: inherit; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s;
}
.cadastro-card:hover, .connection-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.cadastro-card h3 { margin: 0 0 4px; font-size: 1rem; }
.cadastro-card p { margin: 0; color: var(--muted); font-size: .85rem; }

/* Stat cards (dashboard futuro) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; gap: 14px; box-shadow: var(--shadow); }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.stat-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 17px; font-weight: 700; line-height: 1; }

/* ───────────────────────── BUTTONS ───────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 6px 12px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500;
    cursor: pointer; border: 1px solid transparent; transition: all .15s; text-decoration: none; line-height: 1.2;
}
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-lg { padding: 10px 18px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary, .btn-light { background: #f1f5f9; color: var(--text); border-color: var(--border); }
.btn-secondary:hover, .btn-light:hover { background: #e2e8f0; }
.btn-ghost, .btn-outline { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover, .btn-outline:hover { background: #f1f5f9; color: var(--text); }

/* ───────────────────────── TABLES ───────────────────────── */
.table-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap, .work-items-table-wrap, .fc-table-wrap { overflow-x: auto; }
.worklogs-table, .work-items-table, .fc-table, table.tbl {
    width: 100%; border-collapse: collapse; font-size: 11.5px;
}
.worklogs-table thead th, .work-items-table thead th, .fc-table thead th, table.tbl thead th {
    background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 10px;
    text-transform: uppercase; letter-spacing: .04em; padding: 7px 12px;
    text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.worklogs-table tbody td, .work-items-table tbody td, .fc-table tbody td, table.tbl tbody td {
    padding: 6px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle;
}
.worklogs-table tbody tr:hover td, .work-items-table tbody tr:hover td, .fc-table tbody tr:hover td, table.tbl tbody tr:hover td { background: #f8fafc; }
.worklogs-table tbody tr:last-child td, .work-items-table tbody tr:last-child td { border-bottom: none; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell .btn { margin-left: 6px; }
.text-right { text-align: right; } .text-center { text-align: center; }
/* Garante que o alinhamento dos cabeçalhos acompanhe o das células (maior especificidade que a regra base de thead th). */
.worklogs-table thead th.text-right, .work-items-table thead th.text-right, .fc-table thead th.text-right, table.tbl thead th.text-right { text-align: right; }
.worklogs-table thead th.text-center, .work-items-table thead th.text-center, .fc-table thead th.text-center, table.tbl thead th.text-center { text-align: center; }

/* ───────────────────────── FORMS ───────────────────────── */
.form-container { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 26px; max-width: 760px; }
.form-section { padding: 6px 0 18px; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 18px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 14px; }
.form-section-link { font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 600; margin-bottom: 4px; }
.form-label .req { color: var(--danger); }
/* Campo opcional por regra de negocio (Empresa, quando o chamado e do grupo
   inteiro). Marcar so o obrigatorio deixa o opcional ambiguo: em branco por
   escolha ou por esquecimento? */
.form-label .opcional { color: var(--text-muted, #7a8794); font-weight: 400; }

/* Contato do solicitante: e-mail e telefone lado a lado, abaixo do combo.
   O selo de origem diz de onde veio o valor — e, quando diz "Visions", diz
   junto por que o campo nao aceita digitacao. */
.duo-contato { display: grid; grid-template-columns: 1fr 170px; gap: 10px; }
@media (max-width: 640px) { .duo-contato { grid-template-columns: 1fr; } }
.form-label .origem {
    display: inline-flex; align-items: center; font-size: 10px; font-weight: 600;
    border-radius: 20px; padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}
.form-label .origem:empty { display: none; }
.form-label .origem.visions { color: var(--primary-dark); background: var(--primary-50); border: 1px solid #cbe9ec; }
.form-label .origem.local   { color: #3f6212; background: #f7fee7; border: 1px solid #d9f99d; }
.contato-solicitante .form-control[readonly] { background: #f8fafc; color: #475569; }
/* Antes de escolher o solicitante o campo continua na tela, apagado: comunica que
   ainda nao ha a quem pertencer o contato, sem fazer o formulario pular de altura. */
.contato-solicitante .form-control:disabled { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }

/* Chamado de nivel de grupo: a coluna Empresa diz "Todo o grupo". Em italico e mais
   claro para nao ser confundido com o NOME de uma empresa chamada assim. */
.empresa-grupo { font-style: italic; opacity: .75; }
.form-control, .form-textarea, select.form-control {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 12px; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s; outline: none; font-family: inherit;
}
.form-control:focus, .form-textarea:focus, select.form-control:focus {
    border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(1,139,152,.18);
}
.form-control-sm { padding: 5px 8px; font-size: 12px; }
.form-control-lg { padding: 12px 14px; font-size: 15px; }
.form-textarea { min-height: 110px; resize: vertical; }
.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.form-row-3 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.field-error { display: block; color: var(--danger); font-size: 12px; margin-top: 4px; }

/* Campo obrigatório em branco no envio. O balão nativo do navegador está desligado
   (novalidate no form) porque vinha em inglês e se posicionava sozinho — quem avisa
   agora é a mensagem .field-error logo abaixo do campo, com este realce.

   O !important e o seletor com html[data-theme] existem para vencer as regras de
   tema, que também usam !important na borda — sem isso o realce sumia no escuro.
   O editor Quill NÃO ganha filho .ql-container: o próprio #descEditor vira um. */
.form-control.is-invalid,
.form-textarea.is-invalid,
.ql-container.is-invalid,
html[data-theme="dark"] .form-control.is-invalid,
html[data-theme="dark"] .form-textarea.is-invalid,
html[data-theme="dark"] .ql-container.ql-snow.is-invalid { border-color: var(--danger) !important; }
.form-control.is-invalid:focus,
.form-textarea.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.field-error:empty { display: none; }

/* ─── Combos que dependem de outro campo ──────────────────────────────────
   Enquanto a lista é buscada, o próprio combo diz "Carregando…" — é onde o
   usuário já está olhando, e é o que ele lê se abrir a lista no meio da espera.
   Falha e vazio ganham tarja porque, sem elas, os dois viram um "-- Selecione --"
   mudo, igual ao de um site sem cadastro.                                     */
select.combo-carregando { color: var(--muted); font-style: italic; }

.combo-erro, .combo-vazio {
    display: none; margin-top: 6px; padding: 7px 10px;
    border-radius: 6px; font-size: 12px; line-height: 1.5;
}
.combo-erro.on, .combo-vazio.on { display: block; }
.combo-erro  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.combo-vazio { background: #fff7dc; border: 1px solid #f4d374; color: #7a5a00; }
.combo-erro a,
.combo-erro .link-repetir {
    color: #991b1b; font-weight: 600; text-decoration: underline; cursor: pointer;
    background: none; border: none; padding: 0; font-size: inherit; font-family: inherit;
}
.combo-erro .link-repetir:focus-visible { outline: 2px solid #991b1b; outline-offset: 2px; }

/* Diagnóstico da chamada ao Visions: fica fechado e, aberto, tem altura limitada.
   Sem o teto, uma resposta grande do servidor empurra todo o resto do formulário
   para fora da tela — foi o que acontecia quando a API devolvia página de erro. */
.diag-visions { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.diag-visions > summary { cursor: pointer; color: var(--warning); font-weight: 600; }
.diag-visions > summary:hover { text-decoration: underline; }
.diag-visions > span {
    display: block; margin-top: 6px; padding: 8px 10px;
    background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
    white-space: pre-wrap; word-break: break-word;
    max-height: 180px; overflow: auto;
    font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
}

/* Pontinho pulsante do "atualizando automaticamente" — sinal discreto de que a
   tela está viva, sem ocupar espaço nem competir com o conteúdo. */
.pulso {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--primary); display: inline-block; flex: none;
    animation: pulso-bate 2s ease-in-out infinite;
}
@keyframes pulso-bate { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pulso { animation: none; opacity: .6; } }

/* ─── Véu de processamento ────────────────────────────────────────────────
   Cobre a página inteira enquanto uma operação escreve por cima do que o
   usuário está vendo — hoje, a revisão da descrição pela IA. Não tem botão de
   cancelar de propósito: a operação sempre vai até o fim; o que solta a tela é
   a resposta chegar (ou o tempo-limite do próprio JavaScript, para uma rede
   caída não deixar a tela morta).                                            */
.veu-processando {
    position: fixed; inset: 0; z-index: 9000;
    display: none; align-items: center; justify-content: center; padding: 20px;
    background: rgba(71, 85, 105, .45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.veu-processando.on { display: flex; }
.veu-processando .veu-card {
    background: var(--card-bg); border-radius: 14px; padding: 26px 28px;
    max-width: 430px; width: 100%; text-align: center;
    box-shadow: 0 20px 45px rgba(15, 23, 42, .22);
}
.veu-processando .veu-tit  { font-size: 16px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.veu-processando .veu-txt  { font-size: 13px; color: var(--muted); line-height: 1.55; }
.veu-processando .veu-roda {
    width: 44px; height: 44px; margin: 0 auto 14px;
    border: 3px solid var(--primary-50); border-top-color: var(--primary);
    border-radius: 50%; animation: veu-gira .9s linear infinite;
}
@keyframes veu-gira { to { transform: rotate(360deg); } }

/* Barra em vaivém: comunica "estou trabalhando" sem fingir que sabe quanto
   falta — a IA responde de uma vez só, não há progresso real para medir. */
.veu-processando .veu-barra {
    /* var(--border) e não um cinza fixo: no tema escuro um trilho claro brigaria
       com o cartão. */
    height: 5px; border-radius: 99px; background: var(--border);
    overflow: hidden; margin-top: 16px; position: relative;
}
.veu-processando .veu-barra i {
    position: absolute; top: 0; bottom: 0; left: 0; width: 38%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    animation: veu-vaivem 1.25s ease-in-out infinite;
}
@keyframes veu-vaivem { 0% { left: -40%; } 100% { left: 100%; } }

/* Sem animação para quem pediu menos movimento no sistema operacional. */
@media (prefers-reduced-motion: reduce) {
    .veu-processando .veu-roda,
    .veu-processando .veu-barra i { animation: none; }
    .veu-processando .veu-barra i { left: 0; width: 100%; opacity: .5; }
}
.validation-summary { color: var(--danger); font-size: 13px; margin-bottom: 14px; }
.validation-summary ul { margin: 0; padding-left: 18px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; }
.checkbox-label input, .checkbox-input { width: auto; accent-color: var(--primary); }
.input-prefix-group, .input-suffix-group { display: flex; align-items: stretch; }
.input-prefix { display: flex; align-items: center; padding: 0 12px; background: #f1f5f9; border: 1px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-prefix-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-suffix-btn { padding: 0 12px; background: #f1f5f9; border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; cursor: pointer; }
.input-suffix-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* ───────────────────────── BADGES ───────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 10px; font-weight: 600; background: #f1f5f9; color: var(--muted); }
.badge-type, .badge-new, .badge-blue { background: var(--primary-50); color: var(--primary-dark); }
.badge-resolved, .badge-green { background: var(--success-50); color: var(--success); }
/* SLA OK ("No prazo" e "Cumprido") — verde real (#00b33d), distinto do teal padrão. */
.badge-sla-noprazo, .badge-sla-ok { background: #e6f7eb; color: #00b33d; }
.badge-yellow { background: #fefce8; color: var(--warning); }
.badge-red { background: #fef2f2; color: var(--danger); }
.badge-gray, .badge-state { background: #f1f5f9; color: var(--muted); }
.pl-badge-native { background: var(--primary-50); color: var(--primary-dark); padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.pl-badge-custom { background: #fff7ed; color: #c2410c; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.priority-dot, .type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 6px; }
.demonstrativo-table { width: 100%; border-collapse: collapse; }
.demonstrativo-table td { border: 1px solid var(--border, #e2e8f0); padding: 8px 12px; vertical-align: top; }
.demonstrativo-table td.num { text-align: right; font-weight: 600; width: 200px; background: var(--primary-50, #e6f4f5); }
.demonstrativo-table tr:nth-child(odd) td:first-child { background: #f8fafc; }
.demonstrativo-table tr.dem-strong td { background: #cfe7ea; font-weight: 700; }
.demonstrativo-table tr.dem-accent td.num { background: #9dd9de; }
.rel-table { font-size: 10.5px; }
.rel-table td { padding: 4px 6px; white-space: nowrap; }
.rel-table th { padding: 4px 6px; white-space: normal; vertical-align: bottom; line-height: 1.15; }
.rel-table td.num, .rel-table th.num { text-align: right; }
.rel-table td.ctr, .rel-table th.ctr { text-align: center; }
.subtotal-row { background: var(--primary-50, var(--primary-50, #e6f4f5)); }
.subtotal-row td { border-top: 1px solid var(--border, #e2e8f0); }
.tabs-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--border, #e2e8f0); margin-bottom: 16px; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--primary-dark, #016d77); }
.tab-btn.active { color: var(--primary, #018b98); border-bottom-color: var(--primary, #018b98); }
.campo-valores { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.valor-chip { background: #f1f5f9; color: var(--muted); padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; border: 1px solid var(--border, #e2e8f0); }

/* ───────────────────────── ALERTS ───────────────────────── */
/* display:block e NÃO flex. Com flex, cada trecho de texto solto e cada <b>/<a>
   do meio da frase vira um item e o aviso sai em colunas — era o que acontecia
   no aviso do Faturamento em Lote, com "DevOpsUserId" numa coluna própria.
   O ícone é um <span>, então flui inline com o texto sem precisar de flex. */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; display: block; }
.alert-success { background: var(--success-50); color: var(--success); border: 1px solid #b5dee2; }
.alert-error, .alert-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--primary-50); color: var(--primary-dark); border: 1px solid #cfe7ea; }
.alert-icon { font-weight: 700; margin-right: 6px; }

/* ───────────────────────── EMPTY STATE ───────────────────────── */
.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); background: var(--card-bg); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-icon { font-size: 44px; opacity: .35; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; margin-bottom: 14px; }

/* ───────────────────────── HELPERS / LEGADO ───────────────────────── */
.mono, .td-mono { font-family: var(--font-mono); font-size: .85rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.td-hours { color: var(--primary); font-weight: 600; }
.item-title { font-weight: 500; }
.link-external, .breadcrumb-link { color: var(--primary); text-decoration: none; }
.link-external:hover, .breadcrumb-link:hover { text-decoration: underline; }
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-count, .selection-counter { color: var(--muted); font-size: 13px; }

/* Filtros */
.filter-panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; }
.filter-actions { display: flex; gap: 10px; margin-top: 14px; }
/* Filtro que precisa de mais largura que os demais — hoje, a caixa onde se
   colam vários números de chamado. Em tela estreita volta a ocupar 1 coluna. */
.filter-grid .form-group-wide { grid-column: span 2; }
.filter-grid .form-group-wide textarea.form-control { resize: vertical; min-height: 42px; }
@media (max-width: 640px) { .filter-grid .form-group-wide { grid-column: auto; } }

/* Resumo / summary cards (migração OTRS) */
.migration-summary, .pl-fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 20px; }
.summary-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.summary-num { font-size: 24px; font-weight: 700; }
.summary-label { font-size: 12px; color: var(--muted); }
.summary-total .summary-num { color: var(--primary); }
.summary-success .summary-num { color: var(--success); }
.summary-failed .summary-num { color: var(--danger); }
.summary-skipped .summary-num { color: var(--warning); }

/* Lista de projetos (seleção) */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: border-color .12s, transform .12s; }
.project-item:hover { border-color: var(--primary); transform: translateY(-1px); }
.project-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.project-name { font-weight: 600; }
.project-arrow { margin-left: auto; color: var(--muted); }

/* Picklist manager / field config */
.pl-card, .fc-toolbar, .fc-save-bar, .pl-add-form { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pl-card { padding: 16px 18px; }
.pl-card-name { font-weight: 600; }
.pl-card-ref { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.pl-remove-btn, .tt-del-btn { background: none; border: none; color: var(--danger); cursor: pointer; }
.fc-toolbar, .fc-save-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; margin-bottom: 16px; flex-wrap: wrap; }
.option-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: #f1f5f9; border-radius: 99px; font-size: 12px; margin: 2px; }

/* Time tracker */
.tt-user-block { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px; }
.tt-user-name { font-weight: 600; }
.tt-user-total, .tt-daily-pill { color: var(--primary); font-weight: 600; }
.tt-daily-pill { background: var(--primary-50); padding: 2px 10px; border-radius: 99px; font-size: 12px; }

/* ───────────────────────── AUTH (login) ───────────────────────── */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; padding: 24px; background: #ffffff; }
.auth-card { width: 100%; max-width: 420px; background: #ffffff; border: none; border-radius: 0; box-shadow: none; padding: 0 24px; }
.auth-logo { text-align: center; margin-bottom: 36px; }
.auth-logo img { height: 130px; width: auto; max-width: 80%; }
.auth-card h1 { display: none; }
.auth-card .page-subtitle { display: none; }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card .form-control { height: 52px; border-radius: 4px; padding: 14px 16px; font-size: 15px; border: 1px solid #c2cdd6; background: #fff; }
.auth-card .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(1,139,152,.18); outline: none; }
.auth-card .form-label { font-size: 13px; color: #64748b; margin-bottom: 6px; font-weight: 500; }
.auth-card .btn-primary, .auth-card .btn-primary.btn-lg { width: 100%; height: 50px; font-size: 15px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; background: var(--primary); border: none; border-radius: 4px; box-shadow: none; }
.auth-card .btn-primary:hover { background: var(--primary-dark); }
.auth-card .btn-ghost { width: 100%; height: 50px; }
.auth-card .checkbox-label { font-size: 13px; color: #64748b; }

/* Lista de sites no passo 2 (Visions) ─────────────────────────── */
.auth-sites { list-style: none; padding: 0; margin: 0 0 18px; border-top: 1px solid #e2e8f0; }
.auth-site-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid #e2e8f0; cursor: pointer; transition: background .15s; }
.auth-site-row:hover { background: var(--primary-50, #e6f4f5); }
.auth-site-row input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.auth-site-row.selected { background: var(--primary-50, #e6f4f5); }
.auth-site-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-50, #e6f4f5); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.auth-site-nome { font-size: 15px; color: #0f172a; flex: 1; }
.auth-info { text-align: center; color: #475569; font-size: 14px; margin-bottom: 16px; }

/* ───────────────────────── RESPONSIVO ───────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; z-index: 200; transition: transform .25s cubic-bezier(.4,0,.2,1); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.2); }
    .sidebar.collapsed { width: var(--sidebar-width) !important; }
    .sidebar-toggle { display: none !important; }
    .main-wrap, .main-wrap.collapsed { margin-left: 0 !important; }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 199; }
    .sidebar-overlay.active { display: block; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* Linhas de edição inline (Gerenciar Cliente) */
.erp-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.erp-inline .form-control { flex: 1; min-width: 120px; }
.erp-inline-add { border-bottom: none; }

/* Campos configurados do chamado: lado a lado, quebrando quando não couber */
.campos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.campos-grid .form-group { margin-bottom: 0; }

/* ── PicklistManager (layout vertical: 1 card por linha) ────────────────── */
.pl-fields-list { display: flex; flex-direction: column; gap: 12px; }
.pl-card { padding: 14px 18px; transition: opacity .15s; }
.pl-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; cursor: pointer; user-select: none; padding-bottom: 6px; }
.pl-card-titles .pl-card-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.pl-card-titles .pl-card-ref { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pl-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pl-badge { padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.pl-badge-type { background: #ede9fe; color: #4c1d95; }
.pl-badge-count { background: rgba(0,0,0,.05); color: var(--muted); }
.pl-collapse-btn { background: transparent; border: 0; cursor: pointer; padding: 4px 6px; color: var(--muted); }
.pl-card-body { padding-top: 8px; }
.pl-card-body.pl-collapsed { display: none; }

/* Chips */
.pl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pl-chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(0,0,0,.05); padding: 4px 10px; border-radius: 999px; font-size: 13px; transition: opacity .15s, background .15s; }
.pl-chip-readonly { color: var(--muted); }
.pl-chip-inactive { opacity: .45; text-decoration: line-through; background: rgba(220, 38, 38, .08); }
.pl-chip-drag { color: #94a3b8; cursor: grab; font-size: 11px; }
.pl-chip-drag:active { cursor: grabbing; }
.pl-chip-text { line-height: 1.2; }
.pl-chip-action { background: transparent; border: 0; cursor: pointer; padding: 0 2px; color: var(--muted); font-size: 12px; line-height: 1; }
.pl-chip-action:hover { color: var(--text); }
.pl-chip-deactivate:hover { color: var(--danger, #c62828); }
.pl-chip-activate:hover { color: #018b98; }

/* Linha de adicionar */
.pl-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.pl-add-row .pl-add-input { flex: 1; min-width: 220px; }
.pl-readonly-note { color: var(--muted); font-size: 12px; padding: 6px 0; }
.pl-empty { color: var(--muted); font-size: 13px; padding: 8px 0; font-style: italic; }

/* ───────────────────────── RODAPÉ (Desenvolvido por AjaxSolution) ───────────────────────── */
.app-footer {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 7px 24px;
    background: #0f172a; color: #8fa1bd; font-size: 10.5px;
    flex-wrap: wrap;
    /* SEMPRE visível: fixo na base da janela, acompanhando a largura da sidebar. */
    position: fixed; bottom: 0; left: var(--sidebar-width); right: 0; z-index: 40;
}
.main-wrap.collapsed .app-footer { left: var(--sidebar-collapsed); }
.app-footer b { color: #7dd8e0; font-weight: 600; }
/* Reserva espaço no fim do conteúdo pra nada ficar escondido atrás do rodapé fixo. */
.content, .main-content { padding-bottom: 54px; }
@media (max-width: 768px) {
    .app-footer, .main-wrap.collapsed .app-footer { left: 0; }
}

/* ───────────────────────── CARDS DE CONEXÃO OTRS (Importar Chamados) ─────────────────────────
   Grade própria: a de .cards-grid tem coluna mínima de 230px, e o endereço de uma
   conexão por API (https://host:porta/caminho) não cabe nela — ficava cortado na
   borda do card. Aqui a coluna mínima é 320px E o valor pode quebrar linha; só
   alargar não bastaria, uma URL longa continuaria vazando.                              */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.conn-card {
    display: flex; flex-direction: column;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-bg); box-shadow: var(--shadow);
    transition: transform .12s, box-shadow .12s, border-color .12s;
}
.conn-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }

.conn-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.conn-selo {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    background: var(--primary-50); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}

.conn-card-body { padding: 12px 18px 4px; flex: 1; }
.conn-nome { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 10px; overflow-wrap: anywhere; }

.conn-linha { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.conn-rot {
    font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    min-width: 66px; padding-top: 2px; flex-shrink: 0;
}
/* anywhere + break-word: URL sem espaços quebra em qualquer ponto, texto normal
   continua quebrando por palavra. */
.conn-val { font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }
.conn-val.mono { font-family: var(--font-mono); }

.conn-card-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 14px 18px 16px; border-top: 1px solid var(--border); margin-top: 12px;
}
.conn-card-actions .btn { flex: 1 1 auto; white-space: nowrap; }

/* ───────────────────────── TELA "OTRS INDISPONÍVEL" ─────────────────────────
   Substitui a página de exceção do ASP.NET quando o servidor do OTRS não
   responde. Tom de aviso (âmbar), não de erro fatal: nada foi gravado e a
   operação pode ser repetida assim que o OTRS voltar.                          */
.otrs-fora {
    max-width: 820px; background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.otrs-fora-topo { display: flex; gap: 16px; padding: 22px 24px; background: #fffbeb; border-bottom: 1px solid #fde68a; }
.otrs-fora-icone {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    background: #fef3c7; color: #b45309;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.otrs-fora-titulo { font-size: 15px; font-weight: 700; color: #92400e; line-height: 1.3; }
.otrs-fora-frase  { font-size: 12px; color: #92400e; margin-top: 4px; line-height: 1.6; opacity: .92; }

.otrs-fora-corpo { padding: 20px 24px; }
.otrs-bloco-rot { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }

.otrs-dados { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 20px; }
.otrs-dados .lin { display: flex; gap: 12px; padding: 8px 12px; font-size: 11.5px; border-bottom: 1px solid var(--border); }
.otrs-dados .lin:last-child { border-bottom: 0; }
.otrs-dados .lin:nth-child(odd) { background: #f8fafc; }
.otrs-dados .k { color: var(--muted); min-width: 118px; flex-shrink: 0; }
/* Endereço longo quebra em vez de estourar a caixa. */
.otrs-dados .v { overflow-wrap: anywhere; word-break: break-word; }

.otrs-passos { list-style: none; margin-bottom: 4px; }
.otrs-passos li { display: flex; gap: 10px; padding: 7px 0; font-size: 12px; line-height: 1.6; border-bottom: 1px dashed var(--border); }
.otrs-passos li:last-child { border-bottom: 0; }
.otrs-passos .num {
    width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
    background: var(--primary-50); color: var(--primary-dark);
    font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

.otrs-detalhe { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f8fafc; }
.otrs-detalhe summary { cursor: pointer; padding: 9px 12px; font-size: 11.5px; color: var(--muted); font-weight: 600; user-select: none; }
.otrs-detalhe pre {
    padding: 0 12px 12px; font-family: var(--font-mono); font-size: 10.5px; color: #334155;
    white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}

.otrs-fora-acoes {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 16px 24px; border-top: 1px solid var(--border); background: #fcfdfe;
}
.otrs-carimbo { margin-left: auto; font-size: 10.5px; color: var(--muted); }

/* ═════════════════════ LOG DE ERROS ═════════════════════
   Portado da tela equivalente do LineUp, com a paleta do VisionsWorkspace
   (teal no lugar do laranja). Vermelho fica reservado ao que é erro de fato. */
.errvtabs { display: flex; gap: 6px; margin-bottom: 16px; }
.errvtab {
    padding: 8px 20px; font-size: 12.5px; font-weight: 600; border-radius: 9px; cursor: pointer;
    border: 1px solid var(--border); color: var(--muted); background: var(--card-bg);
}
.errvtab.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.errkpis { display: grid; grid-template-columns: repeat(5, 1fr) 210px; gap: 12px; margin-bottom: 18px; }
.errkpi { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; background: var(--card-bg); }
.errkpi .n { font-size: 22px; font-weight: 700; line-height: 1.1; }
.errkpi .l { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.errkpi.red .n { color: var(--danger); }
.errkpi.orange .n { color: var(--warning); }
.errkpi.blue .n { color: var(--primary); }
.errkpi.gray .n { color: var(--muted); }

.errspark { display: flex; align-items: flex-end; gap: 3px; height: 36px; margin-top: 6px; }
.errspark i { flex: 1; background: var(--primary-50); border-radius: 2px 2px 0 0; display: block; min-height: 2px; }
.errspark i.hot { background: var(--primary); }

.errlvl { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 11px; color: #fff; }
.errlvl.err { background: var(--danger); } .errlvl.fatal { background: #7b1f2b; } .errlvl.warn { background: #b58900; }
.errorg { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 11px; }
.errorg.web { background: var(--primary-50); color: var(--primary-dark); }
.errorg.js  { background: #fff8e1; color: #8a6d00; }
.errst { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 11px; white-space: nowrap; }
.errst.aberto { background: #fdecea; color: var(--danger); }
.errst.analise { background: var(--primary-50); color: var(--primary-dark); }
.errst.resolvido { background: #e6f4ea; color: #1e7e34; }
.errst.ignorado { background: #f0f0f2; color: #8a8f98; }
.errcnt { background: var(--primary-50); color: var(--primary-dark); font-weight: 700; font-size: 11px; padding: 3px 10px; border-radius: 11px; }
.erretype { font-family: var(--font-mono); font-size: 11.5px; color: var(--primary-dark); }
.errrota  { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
/* Mensagem em uma linha só: o texto completo está no title e no detalhe. */
.errmsg { max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.errchev { color: #bbb; font-size: 13px; display: inline-block; transition: transform .15s; }
tr.err-open .errchev { transform: rotate(90deg); color: var(--primary); }
tr.errdetrow > td { background: #fbfbfd; padding: 0 !important; border-bottom: 2px solid var(--primary); }

.errdet { padding: 16px 18px; }
.errdethead { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.errdethead .lnk { font-size: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.errtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.errtab { padding: 7px 14px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: 0; }
.errtab.on { color: var(--primary); background: var(--card-bg); border-color: var(--border); }
.errtab .b { background: #eee; border-radius: 9px; font-size: 10px; padding: 1px 7px; margin-left: 5px; color: var(--muted); }

.errpre { background: #232629; color: #e8e8e8; border-radius: 8px; padding: 14px; font-family: var(--font-mono); font-size: 11.5px; line-height: 1.55; overflow: auto; max-height: 280px; white-space: pre-wrap; }
.errpre .ex { color: #ff8a80; font-weight: 600; }
.errpre .inner { color: #ffd54f; }
.errpre .at { color: #9aa4ad; }
/* Verde nos frames do próprio código: é onde está a causa. */
.errpre .mine { color: #a5d6a7; }

.errkvt { border-collapse: collapse; }
.errkvt td, .errkvt th { padding: 6px 12px; font-size: 12px; border-bottom: 1px solid #f0f1f4; text-align: left; }
.errkvt td:first-child { font-family: var(--font-mono); color: var(--primary-dark); font-size: 11.5px; white-space: nowrap; }
.errkvt tr.bad td { background: #fdecea; }
.errkvt tr.bad td:last-child { color: var(--danger); font-weight: 700; }

.errreq { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 22px; }
.errreq .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.errreq .v { font-size: 12px; font-family: var(--font-mono); word-break: break-all; }

.errtl { border-left: 2px solid var(--border); margin: 6px 0 0 8px; padding-left: 18px; }
.errtl .ev { position: relative; padding-bottom: 12px; font-size: 12px; }
.errtl .ev::before { content: ''; position: absolute; left: -24px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #c9ccd4; }
.errtl .ev.err::before { background: var(--danger); box-shadow: 0 0 0 3px #fdecea; }
.errtl .ev .t { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-right: 8px; }
.errtl .ev.err { color: var(--danger); font-weight: 600; }
.errtl .ev .aud { font-size: 10px; background: var(--primary-50); color: var(--primary-dark); border-radius: 9px; padding: 1px 7px; margin-left: 6px; }

.errsim { display: flex; gap: 10px; font-size: 11.5px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.errnotes { background: #fffbe8; border: 1px solid #ffe08a; border-radius: 8px; font-size: 11.5px; color: #7a5b00; padding: 8px 12px; margin-top: 12px; }
.errfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; flex-wrap: wrap; gap: 10px; }

.errdash { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; }
.errdcard { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--card-bg); }
.errdcard h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .03em; }
.errbars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.errbars i { flex: 1; background: var(--primary-50); border-radius: 3px 3px 0 0; min-height: 2px; }
.errbars i.hot { background: var(--primary); }
.errhbar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 11.5px; }
.errhbar .lb { width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 11px; }
.errhbar .tr { flex: 1; background: #f4f5f7; border-radius: 4px; height: 14px; overflow: hidden; }
.errhbar .tr i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.errhbar .n { width: 30px; text-align: right; font-weight: 700; color: var(--muted); font-size: 11px; }
.errheat { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.errheat i { aspect-ratio: 1; border-radius: 2px; background: #f4f5f7; }
.errheat i.h1 { background: #cdeaed; } .errheat i.h2 { background: #7fc9d0; }
.errheat i.h3 { background: var(--primary); } .errheat i.h4 { background: var(--primary-dark); }
.errheatlbl { display: flex; justify-content: space-between; font-size: 9px; color: var(--muted); margin-top: 3px; }

@media (max-width: 1100px) {
    .errkpis { grid-template-columns: repeat(2, 1fr); }
    .errdash { grid-template-columns: 1fr; }
    .errdash .errdcard[style*="grid-column"] { grid-column: auto !important; }
    .errreq { grid-template-columns: repeat(2, 1fr); }
}

/* ═════════════════════ LOG DE AUDITORIA ═════════════════════ */
tr.aud-main { cursor: pointer; }
tr.aud-main:hover td { background: #fafbfd; }
tr.aud-main.open td { background: var(--primary-50); }
.aud-chev { color: #bbb; display: inline-block; transition: transform .15s; }
tr.aud-main.open .aud-chev { transform: rotate(90deg); color: var(--primary); }
.aud-mono { font-family: var(--font-mono); font-size: 11px; }
tr.aud-detail > td { background: #fbfbfd; padding: 18px 22px; border-bottom: 2px solid var(--primary); }

.aud-op { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; border-radius: 20px; padding: 3px 11px; }
.aud-op.create { background: #eefaf0; color: #28a745; }
.aud-op.update { background: var(--primary-50); color: var(--primary-dark); }
.aud-op.delete { background: #fdecec; color: var(--danger); }
.aud-op.upload { background: #fff8e6; color: #8a6d00; }

.aud-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 12px; }
.aud-meta .m .k { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.aud-meta .m .v { font-size: 12.5px; font-weight: 600; margin-top: 1px; }
.aud-sec { font-size: 12.5px; font-weight: 700; margin: 14px 0 8px; display: flex; align-items: center; gap: 7px; }
.aud-sec.teal { color: var(--primary); } .aud-sec.blue { color: #0d6efd; }

.aud-diff { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-bottom: 6px; }
.aud-diff th { background: #f2f3f6; font-weight: 700; padding: 6px 10px; text-align: left; border: 1px solid #e6e8ec; }
.aud-diff td { padding: 6px 10px; border: 1px solid #eceef2; vertical-align: top; word-break: break-word; }
.aud-diff td.campo { font-weight: 600; width: 220px; }
/* Riscado no antigo, verde no novo: dá para ler o diff sem comparar coluna a coluna. */
.aud-diff .old { background: #fdf3f4; color: #a13d47; text-decoration: line-through; }
.aud-diff .new { background: #eefaf0; color: #1e7c37; font-weight: 600; }
.aud-diff tr.same td:not(.campo) { color: #8b93a0; }
.aud-diff tr.rel td { background: #f6f9ff; }
.aud-diff tr.rel td.campo { color: #2b5a8c; }
.aud-grupo td { background: #eef4fb !important; font-weight: 700; color: #2b5a8c; font-size: 11px; letter-spacing: .4px; }
.aud-badge { font-size: 9.5px; background: var(--primary); color: #fff; border-radius: 8px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }

.aud-diff tr.idrow td { background: var(--primary-50); border-top: 2px solid var(--primary); border-bottom: 2px solid var(--primary); padding-top: 11px; padding-bottom: 11px; }
.aud-diff tr.idrow .campo { color: var(--primary-dark); font-weight: 700; font-size: 12.5px; }
.aud-diff .idval { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.aud-diff .idnota { font-size: 11px; color: var(--muted); margin-left: 8px; }
.aud-copy { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 2px 8px; font-size: 10.5px; color: var(--muted); cursor: pointer; margin-left: 8px; font-family: inherit; }

.aud-jsons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.aud-json { background: #20242c; color: #c8cfda; border-radius: 10px; padding: 12px 14px; overflow: auto; max-height: 300px; }
.aud-json .hdr { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; margin-bottom: 8px; }
.aud-json.old .hdr { color: #ff8b95; } .aud-json.new .hdr { color: #7ee2a0; }
.aud-json pre { margin: 0; font-family: var(--font-mono); font-size: 10.5px; line-height: 1.6; white-space: pre-wrap; color: inherit; }

@media (max-width: 900px) { .aud-jsons { grid-template-columns: 1fr; } }

/* ═════════════════════ PÁGINA DE ERRO ═════════════════════
   Sem detalhe, um cartão centralizado resolve. COM detalhe, a página usa toda a
   largura: stack trace numa coluna estreita, quebrando cada linha no meio, é
   ilegível — e é justamente o que se precisa ler ali.                          */
.err-page { max-width: 560px; margin: 48px auto; }
.err-page.com-detalhe { max-width: none; margin: 8px 0 0; }

.err-aviso {
    display: flex; align-items: flex-start; gap: 16px;
    background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 16px;
}
.err-aviso-ic {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: #fef3c7; color: #b45309;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.err-aviso-tt { font-size: 16px; font-weight: 700; color: #92400e; line-height: 1.3; }
.err-aviso-ds { font-size: 12px; color: #92400e; opacity: .92; margin-top: 4px; line-height: 1.6; max-width: 70ch; }

.err-detalhe {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px;
}
.err-detalhe-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.err-detalhe-topo h2 { font-size: 14px; font-weight: 700; color: var(--danger); }
.err-detalhe-topo h2 span { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 6px; text-transform: none; }

.err-linha { display: flex; gap: 10px; font-size: 11.5px; padding: 3px 0; }
.err-linha .k { color: var(--muted); min-width: 62px; }
.err-linha .v { overflow-wrap: anywhere; }

.err-msg {
    font-size: 12.5px; background: #fceaea; color: #791f1f;
    border: 1px solid #f6cccc; border-radius: var(--radius-sm);
    padding: 10px 12px; margin: 10px 0 12px; line-height: 1.6;
    overflow-wrap: anywhere;
}

.err-detalhe details > summary {
    font-size: 11.5px; cursor: pointer; color: var(--muted); font-weight: 600;
    padding: 4px 0; user-select: none;
}
/* white-space: pre (e NÃO pre-wrap): a linha longa rola na horizontal em vez de
   quebrar no meio do nome do método. */
.err-stack {
    font-family: var(--font-mono); font-size: 11px; line-height: 1.65;
    background: #232629; color: #e8e8e8;
    padding: 12px 14px; border-radius: var(--radius-sm);
    max-height: 460px; overflow: auto; white-space: pre; margin-top: 6px;
}

/* ── Link de acesso por SSO, no detalhe do evento de auditoria ────────────── */
.acc-link { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: #fbfcfe; }
.acc-topo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.acc-topo label { font-size: 11px; color: var(--muted); font-weight: 600; }
.acc-topo .acc-dest { width: 180px; }
/* A URL sai numa linha só e rola: quebrar um JWT em várias linhas é o caminho
   mais curto para alguém copiar pela metade. */
.acc-url {
    width: 100%; font-size: 11px; padding: 7px 9px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; color: var(--text); white-space: nowrap; overflow-x: auto;
}
.acc-aviso { font-size: 11px; color: var(--muted); margin-top: 6px; }
.acc-aviso.venceu { color: #b91c1c; font-weight: 600; }

/* ─── Combo com busca por digitação ───────────────────────────────────────
   O <select> continua sendo quem guarda e posta o valor; ele só sai de vista.
   display:none e não visibility/opacity: um select fora de tela ainda recebe
   foco pelo Tab, e a pessoa cairia num campo invisível no meio do formulário.
   (Ver combo-busca.js — o required é transferido para o campo de texto, que é
   o que o validador da tela enxerga.)                                        */
.combo-busca { position: relative; }
.combo-busca-fonte { display: none !important; }
.combo-busca > input { padding-right: 54px; }
.combo-busca > input.combo-carregando { color: var(--muted); font-style: italic; }

.combo-busca-acoes {
    position: absolute; top: 0; right: 0; height: 100%;
    display: flex; align-items: center; gap: 2px; padding-right: 8px;
}
.combo-busca-acoes .cb-limpar {
    border: none; background: none; color: var(--muted); cursor: pointer;
    font-size: 13px; line-height: 1; padding: 4px 5px; border-radius: 5px;
}
.combo-busca-acoes .cb-limpar:hover { background: var(--primary-50); color: var(--primary-dark); }
.combo-busca-acoes .cb-limpar:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.combo-busca-acoes .cb-seta { color: var(--muted); font-size: 10px; cursor: pointer; padding-right: 2px; }

/* z-index alto: a lista precisa passar por cima dos campos seguintes do
   formulário — e o véu de processamento da IA (9000) segue acima dela. */
.combo-busca-lista {
    position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 10px 24px rgba(15, 23, 42, .13);
    max-height: 240px; overflow: auto; display: none;
}
.combo-busca-lista.on { display: block; }
.combo-busca-lista .cb-it {
    padding: 8px 12px; font-size: 12.5px; cursor: pointer;
    display: flex; justify-content: space-between; gap: 10px; color: var(--text);
}
.combo-busca-lista .cb-it:hover,
.combo-busca-lista .cb-it.ativo { background: var(--primary-50); }
.combo-busca-lista .cb-it.ativo { box-shadow: inset 3px 0 0 var(--primary); }
/* Realce do trecho encontrado. Fundo próprio (e não só negrito) porque em nome
   curto o negrito sozinho quase não se distingue. */
.combo-busca-lista .cb-it b { color: var(--primary-dark); background: var(--primary-50); border-radius: 3px; }
.combo-busca-lista .cb-it.ativo b,
.combo-busca-lista .cb-it:hover b { background: transparent; }
.combo-busca-lista .cb-sec { color: var(--muted); font-size: 11px; flex: none; }
.combo-busca-lista .cb-nada { padding: 12px; font-size: 12px; color: var(--muted); }
.combo-busca-lista .cb-nada span { font-size: 11px; }
.combo-busca-lista .cb-conta {
    padding: 6px 12px; font-size: 10.5px; color: var(--muted);
    border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .5px;
    position: sticky; top: 0; background: var(--card-bg);
}

/* Selo de origem no item da busca (ex.: Solicitante) — Visions x cadastro
   local. Mesma paleta do selo que já existe ao lado de E-mail/Telefone
   (.form-label .origem, mais abaixo neste arquivo), reaproveitada aqui num
   seletor próprio porque o item da lista não está dentro de .form-label.
   Ver combo-busca.js (opts.origem) e a tela que decora o combo. */
.combo-busca-lista .cb-nome { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.combo-busca-lista .cb-origem {
    display: inline-flex; align-items: center; flex: none;
    font-size: 9.5px; font-weight: 700; letter-spacing: .01em;
    border-radius: 20px; padding: 1.5px 7px;
}
.combo-busca-lista .cb-origem.visions { color: var(--primary-dark); background: var(--primary-50); border: 1px solid #cbe9ec; }
.combo-busca-lista .cb-origem.local   { color: #3f6212; background: #f7fee7; border: 1px solid #d9f99d; }

/* ─── Anexos: lista na tela e escolha cumulativa ──────────────────────────
   O <input type="file"> continua sendo quem posta; ele só sai de vista, e o
   botão da zona é que o aciona. display:none e não opacity: um campo de arquivo
   fora de tela ainda pega o Tab, e a pessoa cairia num controle invisível.
   (Ver anexos.js — sem DataTransfer no navegador nada é decorado e o campo
   nativo reaparece por si, porque a classe abaixo nunca chega a ser aplicada.) */
.anx-fonte { display: none !important; }

.anx-zona {
    border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
    padding: 16px; text-align: center; background: #fcfdfe;
    transition: border-color .15s, background .15s;
}
.anx-zona.sobre { border-color: var(--primary); background: var(--primary-50); }
.anx-zona .anx-ou { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

.anx-lista {
    margin-top: 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
}
.anx-it {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    font-size: 12.5px; border-bottom: 1px solid var(--border); background: var(--card-bg);
}
.anx-it:last-child { border-bottom: none; }
/* Etiqueta da extensão: diz o tipo do arquivo sem depender de um pacote de
   ícones só para isso. */
.anx-it .anx-ic {
    flex: none; width: 26px; height: 26px; border-radius: 6px;
    background: var(--primary-50); color: var(--primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 800; letter-spacing: .3px;
}
/* min-width:0 é o que permite o text-overflow funcionar dentro do flex — sem
   ele o nome comprido empurra o tamanho e o "remover" para fora da caixa. */
.anx-it .anx-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anx-it .anx-tm { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.anx-it .anx-rm {
    flex: none; border: none; background: none; color: var(--muted); cursor: pointer;
    font-size: 13px; padding: 3px 6px; border-radius: 5px; line-height: 1;
}
.anx-it .anx-rm:hover { background: #fef2f2; color: var(--danger); }
.anx-it .anx-rm:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

/* O recém-chegado pisca de leve: numa lista de dez, é o que diz qual acabou de
   entrar. */
.anx-it.novo { animation: anx-entra .45s ease; }
@keyframes anx-entra { from { background: var(--primary-50); } to { background: var(--card-bg); } }
@media (prefers-reduced-motion: reduce) { .anx-it.novo { animation: none; } }

.anx-vazio { font-size: 11.5px; color: var(--muted); margin: 10px 0 0; text-align: center; }
.anx-rodape {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    margin-top: 8px; font-size: 11.5px; color: var(--muted);
}
.anx-rodape .anx-limpar {
    border: none; background: none; color: var(--muted); cursor: pointer;
    text-decoration: underline; font-size: 11.5px; padding: 0;
}
.anx-rodape .anx-limpar:hover { color: var(--danger); }

/* Recusa (passou do limite, arquivo vazio) e aviso (repetido). Some na escolha
   seguinte — não vira sujeira permanente na tela. */
.anx-avisos > div { margin-top: 10px; padding: 8px 10px; border-radius: 6px; font-size: 11.5px; line-height: 1.5; }
.anx-erro   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.anx-alerta { background: #fff7dc; border: 1px solid #f4d374; color: #7a5a00; }

/* ─── Competência (mês/ano) ────────────────────────────────────────────────
   O <input type="month"> só é implementado por parte dos navegadores — no
   Safari ele vira uma caixa de texto vazia. Estes estilos vestem o campo que o
   campo-competencia.js põe por cima; o original continua no formulário, só que
   escondido, e é ele que posta o AAAA-MM.
   (Sem o .js nada disto é aplicado, porque nenhuma destas classes chega ao DOM.) */
.cmp { position: relative; }
.cmp-fonte { display: none !important; }
.cmp > input { padding-right: 54px; }

.cmp-acoes {
    position: absolute; top: 0; right: 0; height: 100%;
    display: flex; align-items: center; gap: 2px; padding-right: 8px;
}
.cmp-acoes button {
    border: none; background: none; color: var(--muted); cursor: pointer;
    line-height: 1; padding: 4px 5px; border-radius: 5px; font-size: 12px;
    /* min-width porque o botão de abrir usa ícone do Font Awesome: se a fonte não
       carregar, o <i> fica sem conteúdo e o botão viraria um alvo de zero pixel. */
    min-width: 20px;
}
.cmp-acoes button:hover { background: var(--primary-50); color: var(--primary-dark); }
.cmp-acoes button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Mesmo z-index da lista do combo-busca: o painel precisa passar por cima dos
   campos seguintes do formulário, e o véu da IA (9000) segue acima dele. */
.cmp-painel {
    position: absolute; z-index: 60; left: 0; top: calc(100% + 4px); width: 250px;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 10px 24px rgba(15, 23, 42, .13);
    display: none; padding: 10px;
}
.cmp-painel.on { display: block; }

.cmp-ano { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cmp-ano button {
    border: 1px solid var(--border); background: var(--card-bg); border-radius: 5px;
    cursor: pointer; color: var(--muted); width: 26px; height: 24px; line-height: 1; font-size: 12px;
}
.cmp-ano button:hover { border-color: var(--primary-light); color: var(--primary-dark); }
.cmp-ano strong { font-size: 13px; font-variant-numeric: tabular-nums; }

.cmp-meses { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.cmp-meses button {
    border: 1px solid transparent; background: var(--bg); border-radius: 5px;
    cursor: pointer; padding: 7px 0; font: inherit; font-size: 11.5px; color: var(--text);
}
.cmp-meses button:hover { background: var(--primary-50); color: var(--primary-dark); }
.cmp-meses button.sel  { background: var(--primary); color: #fff; font-weight: 600; }
/* Contorno no mês corrente: dá um ponto de referência sem competir com o escolhido. */
.cmp-meses button.hoje { border-color: var(--primary-light); }

.cmp-rodape {
    display: flex; justify-content: space-between;
    margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--border);
}
.cmp-rodape button {
    border: none; background: none; color: var(--primary-dark);
    cursor: pointer; font: inherit; font-size: 11px; padding: 3px 5px; border-radius: 5px;
}
.cmp-rodape button:hover { background: var(--primary-50); }
