:root {
    --azul: #1a82b8;
    --azul-escuro: #155d8c;
    --verde: #19a88b;
    --verde-escuro: #138a72;
    --navy: #0d3b5e;
    --vermelho: #e63030;
    --amarelo: #f5c500;
    --fundo: #f4f6f9;
    --texto: #1e3a50;
    --mudo: #718096;
    --linha: #e2e8f0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, "Segoe UI", sans-serif;
    background: var(--fundo);
    color: var(--texto);
    line-height: 1.45;
    min-height: 100vh;
}

a { color: var(--azul); }

.faixa {
    height: 4px;
    background: linear-gradient(90deg, #e63030, #f5c500, #1a82b8);
}

.nav {
    background: var(--navy);
    border-bottom: 3px solid var(--azul);
    color: white;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 28px;
}

.nav img { height: 44px; }

.nav a.marca {
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
}

.nav span { color: #c5d4e0; font-size: 14px; }
.nav .menu { display: flex; gap: 16px; margin-left: 8px; }
.nav .menu a { color: white; text-decoration: none; font-weight: 600; font-size: 14px; }
.nav .menu a:hover { color: #f5c500; }
.nav .operador { margin-left: auto; color: white; font-weight: 600; }
a.menu-card { display: block; text-decoration: none; color: inherit; }
a.menu-card:hover { box-shadow: 0 6px 18px rgba(13, 59, 94, 0.12); }
.nav a.sair { color: white; text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a.sair:hover { color: #f5c500; }
.nav a.atalho-datasus {
    margin-left: auto;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    background: var(--azul);
    border-radius: 6px;
    padding: 8px 14px;
}
.nav a.atalho-datasus:hover { background: var(--azul-escuro); color: white; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 72px; }

h1 { font-size: 28px; color: var(--navy); margin: 0 0 8px; }
h2 { font-size: 18px; color: var(--navy); margin: 0 0 12px; }
p.lead { color: var(--mudo); margin-top: 0; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(13, 59, 94, 0.08);
    padding: 16px 18px;
}

.card .num { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.15; }
.card .num-valor { font-size: 20px; white-space: nowrap; }
.card .lbl { color: var(--mudo); font-size: 13px; }
.card.alerta { box-shadow: inset 4px 0 0 var(--amarelo); }
.card.erro { box-shadow: inset 4px 0 0 var(--vermelho); }
.card.ok { box-shadow: inset 4px 0 0 var(--verde); }

.secao { margin-top: 22px; }

.linha-acoes, .form-linha {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.acoes-remessa { flex-wrap: nowrap; }
.acoes-remessa form { margin: 0; }

.btn, button.btn {
    background: var(--azul);
    color: white;
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    white-space: nowrap;
}

.btn .icone { width: 16px; height: 16px; flex: none; display: block; }
.btn-icone { width: 36px; height: 36px; padding: 0; justify-content: center; }

.btn:hover { background: var(--azul-escuro); }
.btn-sec { background: var(--verde); }
.btn-sec:hover { background: var(--verde-escuro); }
.btn-analisar { background: var(--navy); }
.btn-analisar:hover { background: #08283f; }
.btn-perigo { background: var(--vermelho); }
.btn-perigo:hover { background: #c42828; }
.btn-claro {
    background: white;
    color: var(--navy);
    border: 1px solid #cbd5e0;
}
.btn-claro:hover { background: #eef3f7; }
.btn-claro.ativo, .btn-claro.ativo:hover { background: var(--navy); color: white; border-color: var(--navy); }
.btn:disabled, .btn[disabled] { background: #a0aec0; cursor: not-allowed; }

input[type="month"], input[type="file"], input[type="search"], input[type="text"], input[type="password"], select {
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 8px 10px;
    font-family: inherit;
    color: var(--texto);
    background: white;
}

.login-caixa { max-width: 420px; margin: 36px auto; padding: 28px 28px 24px; }
.abas { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.abas a {
    background: white;
    color: var(--navy);
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    padding: 8px 12px;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
}
.abas a:hover, .abas a.ativa { background: var(--navy); color: white; border-color: var(--navy); }
.filtro-arquivo { display: block; font-weight: 600; font-size: 13px; color: var(--navy); margin-bottom: 6px; }
#filtro-arquivo { width: min(360px, 100%); }
.login-logo { height: 56px; display: block; margin: 0 auto 16px; }
.form-unidade { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin-top: 12px; }
.form-unidade label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; color: var(--navy); }
.form-unidade .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; min-height: 38px; }
.login-caixa label { display: block; font-weight: 600; margin: 14px 0 6px; }
.login-caixa input { width: 100%; }
.login-caixa .btn { margin: 18px auto 0; display: block; width: fit-content; }

.aviso {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0;
    border-left: 4px solid var(--azul);
}

.aviso.erro { border-left-color: var(--vermelho); background: #fff6f6; }
.aviso.ok { border-left-color: var(--verde); background: #f3fbf8; }
.aviso.alerta { border-left-color: var(--amarelo); background: #fffbeb; }

.flash {
    background: #e8f4fb;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--linha);
    vertical-align: top;
}

th { background: #f4f6f9; color: var(--navy); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.duplicado { background: #fff1f1; }
tr.instrumento, tr.ausente { background: #fffbeb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tabela-rolagem { overflow-x: auto; border-radius: 12px; box-shadow: 0 1px 3px rgba(13, 59, 94, 0.08); }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-erro { background: #fde8e8; color: #b42318; }
.badge-alerta { background: #fff6d6; color: #8a6a00; }
.badge-ok { background: #e7f7f3; color: #0f7a64; }
.badge-ambos { background: #fff6d6; color: #8a6a00; }
.badge-c { background: #e8f4fb; color: var(--navy); }
.badge-i { background: #e7f7f3; color: #0f7a64; }

footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    text-align: center;
    color: var(--mudo);
    font-size: 13px;
    padding: 10px 16px;
    background: var(--fundo);
    border-top: 1px solid var(--linha);
}

body.travado { overflow: hidden; }
.trava {
    position: fixed;
    inset: 0;
    background: rgba(13, 59, 94, 0.45);
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.trava[hidden] { display: none; }
.trava-caixa {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: min(520px, 100%);
    box-shadow: 0 12px 40px rgba(13, 59, 94, 0.2);
}
.trava-caixa h2 { margin-top: 0; }
.barra {
    height: 14px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.barra > span {
    display: block;
    height: 100%;
    width: 0;
    background: #1a82b8;
}
.trava .log { max-height: 180px; overflow: auto; }

pre.log {
    background: var(--navy);
    color: #e8f4fb;
    border-radius: 12px;
    padding: 16px;
    min-height: 140px;
    white-space: pre-wrap;
}

.tipo-unidades {
    position: relative;
    cursor: help;
    font-weight: 700;
    color: var(--navy);
    border-bottom: 1px dashed var(--azul);
    white-space: nowrap;
}
.tipo-dica {
    display: none;
    position: fixed;
    z-index: 40;
    width: min(460px, calc(100vw - 24px));
    max-height: 320px;
    overflow: auto;
    background: white;
    color: var(--texto);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(13, 59, 94, 0.18);
    padding: 12px 14px;
    text-align: left;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.4;
}
.tipo-dica.aberta { display: block; }
.tipo-dica strong { display: block; color: var(--navy); margin-bottom: 4px; }
.tipo-dica p { margin: 0 0 8px; color: var(--mudo); }
.tipo-dica ul { margin: 8px 0 0; padding-left: 18px; }
.tipo-dica li { margin: 4px 0; }
.tipo-dica code { font-weight: 700; }

.paginacao { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.mudo { color: var(--mudo); }
code { font-family: Consolas, monospace; font-size: 13px; }
