:root {
    --navy: #0f3d5c;
    --navy-dark: #0a2b41;
    --gold: #d4a017;
    --paper: #f4f1ea;
    --white: #fffdf8;
    --ink: #1d2a33;
    --muted: #5b6b75;
    --line: #d7e0e8;
    --ok: #1f7a4d;
    --run: #1b6aa3;
    --late: #b42318;
    --hold: #7a5c00;
    --idle: #5b6b75;
}

* { box-sizing: border-box; }
html, body {
    min-height: 100%;
}
body {
    margin: 0;
    font-family: Figtree, ui-sans-serif, system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea {
    font: inherit;
}
.app {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
    min-height: 100dvh;
}
.menu-topo,
.menu-fundo,
.menu-fechar { display: none; }
.sidebar {
    flex: 0 0 260px;
    width: 260px;
    max-width: 260px;
    background: linear-gradient(180deg, var(--navy-dark), var(--navy));
    color: white;
    padding: 1.5rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 100%;
}
.barra-conta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: .55rem 1.2rem;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 25;
}
.conta-slot-mobile { display: none; margin-left: auto; }
.conta-menu { position: relative; }
.conta-botao {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 2px solid var(--gold);
    border-radius: 50%;
    overflow: hidden;
    background: var(--navy);
    cursor: pointer;
    color: var(--navy-dark);
}
.conta-foto {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.conta-iniciais {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--gold);
    font-weight: 700;
    font-size: .95rem;
}
.conta-painel {
    position: absolute;
    top: calc(100% + .45rem);
    right: 0;
    z-index: 60;
    min-width: 230px;
    background: var(--white);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,.16);
    padding: .4rem;
}
.conta-dados {
    padding: .55rem .7rem .7rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: .35rem;
}
.conta-dados strong { display: block; }
.conta-dados small { display: block; color: var(--muted); }
.conta-painel a,
.conta-painel button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--ink);
    padding: .55rem .7rem;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}
.conta-painel a:hover,
.conta-painel button:hover {
    background: #eef4f7;
    text-decoration: none;
}
.conta-painel form { margin: 0; }
.conta-painel form button { color: var(--late); }
.conteudo { padding: 2rem; min-height: 0; flex: 1; }
.brand strong { display: block; font-size: 1.3rem; }
.brand small, .brand-kicker {
    display: block;
    color: #c9d7e3;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.sidebar nav { display: grid; gap: .4rem; }
.sidebar nav a {
    color: white;
    padding: .7rem .8rem;
    border-radius: 10px;
    text-decoration: none;
}
.sidebar nav a.ativo,
.sidebar nav a:hover {
    background: rgba(255,255,255,.12);
    text-decoration: none;
}
.sidebar-user {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,.15);
    padding-top: 1rem;
    font-size: .9rem;
}
.sidebar-user button {
    margin-top: .6rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,.3);
    color: white;
    border-radius: 8px;
    padding: .4rem .7rem;
    cursor: pointer;
}
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-head h1 { margin: .2rem 0 .4rem; font-size: 1.7rem; width: 100%; }
.page-head p { color: var(--muted); max-width: 70ch; }
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .8rem;
    margin: 1.2rem 0;
}
.kpis article {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem;
}
.kpis span { color: var(--muted); font-size: .8rem; }
.kpis strong { display: block; font-size: 1.4rem; margin-top: .3rem; }
.progresso {
    height: 10px;
    background: #e4ebe8;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 1.2rem;
}
.progresso .barra {
    height: 100%;
    background: var(--gold);
}
.tabela-wrap {
    overflow: auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef4f7; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.1rem;
    color: inherit;
    text-decoration: none;
    display: block;
}
.card:hover { border-color: var(--navy); text-decoration: none; }
.card .num {
    color: var(--gold);
    font-weight: 700;
    font-size: 1.1rem;
}
.card h2 { font-size: 1.05rem; margin: .4rem 0; }
.card p { color: var(--muted); font-size: .9rem; }
.meta-line { display: flex; gap: .8rem; font-size: .78rem; color: var(--navy); margin-top: .8rem; }
.grupo-bloco { margin-bottom: 1.8rem; }
.grupo-bloco > header { margin-bottom: 1rem; }
.grupo-bloco > header h2 { margin: 0 0 .35rem; font-size: 1.2rem; }
.grupo-bloco > header p { margin: 0; color: var(--muted); max-width: 80ch; }
.cabeca-bloco td {
    background: var(--navy);
    color: white;
    font-size: .82rem;
    letter-spacing: .02em;
    border-bottom: 0;
}
.cabeca-bloco small {
    display: block;
    font-weight: 400;
    opacity: .85;
    margin-top: .25rem;
    text-transform: none;
    letter-spacing: 0;
}
.bloco {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}
.item {
    border-top: 1px solid var(--line);
    padding: 1rem 0;
}
.item header { display: flex; gap: .7rem; align-items: center; }
.descricao { color: var(--muted); line-height: 1.45; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .8rem;
    margin-top: .8rem;
}
.form-grid.compact { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.form-grid.compact .span-2 { grid-column: 1 / -1; }
label { display: grid; gap: .35rem; font-size: .85rem; font-weight: 600; }
input, select, textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .55rem .7rem;
    background: #fff;
}
button[type=submit] {
    background: var(--navy);
    color: white;
    border: 0;
    border-radius: 8px;
    padding: .7rem 1rem;
    cursor: pointer;
}
.anos {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .5rem;
}
.badge {
    font-size: .72rem;
    font-weight: 700;
    border-radius: 99px;
    padding: .2rem .55rem;
}
.badge-ok { background: #e4f6ec; color: var(--ok); }
.badge-run { background: #e3f1fb; color: var(--run); }
.badge-late { background: #fde8e6; color: var(--late); }
.badge-hold { background: #fff4d6; color: var(--hold); }
.badge-idle { background: #eef1f4; color: var(--idle); }
.alerta {
    background: #e8f6ea;
    border: 1px solid #b7e0c2;
    color: var(--ok);
    padding: .8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}
.filtros {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: .6rem;
    margin-bottom: 1rem;
}
.filtros-auditoria {
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
}
.log-caixa {
    background: #0f3d5c;
    color: #e8f0f5;
    border-radius: 10px;
    padding: 1rem;
    overflow: auto;
    max-height: 32rem;
    font-size: .78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(circle at top, #1a567c, var(--navy-dark));
}
.login-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem 0;
}
.login-card {
    width: min(460px, calc(100% - 2rem));
    background: var(--white);
    padding: 2rem;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
    margin: auto;
}
.login-logo { display: block; height: 72px; margin: 0 auto 1rem; object-fit: contain; }
.login-kicker {
    color: #b8860b !important;
    text-align: center;
    font-weight: 700;
}
.login-card h1 { margin: .3rem 0 0; text-align: center; }
.login-lead { color: var(--muted); text-align: center; }
.login-card form { display: grid; gap: .8rem; margin-top: 1rem; }
.sidebar-logo { width: min(100%, 190px); margin-bottom: .5rem; display: block; }
.brand-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.rodape {
    margin-top: auto;
    padding: 1rem 1.2rem;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    background: var(--white);
    width: 100%;
}
.rodape p { margin: .3rem 0 0; }
.rodape a { color: var(--navy); }
.rodape-logo { height: 38px; display: block; margin: 0 auto; object-fit: contain; }
.login-body .rodape {
    border: 0;
    color: #d7e6ef;
    background: transparent;
    padding: 1rem 1.2rem 1.4rem;
}
.login-body .rodape a { color: #fff; }
.login-body .rodape-logo { height: 44px; }
.preview-logo img { max-height: 80px; max-width: 180px; object-fit: contain; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.hint { color: var(--muted); font-size: .85rem; }
.erro { color: var(--late); }
.breadcrumb { font-size: .85rem; }
.leitura dt { font-weight: 700; margin-top: .6rem; }
.leitura dd { margin: .2rem 0 0; color: var(--muted); }
.paginacao-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    margin-top: 1rem;
}
.paginacao-info { margin: 0; color: var(--muted); font-size: .9rem; }
.paginacao-lista {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.paginacao-lista a,
.paginacao-lista span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    padding: .4rem .7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    color: var(--navy);
    text-decoration: none;
}
.paginacao-lista a:hover { background: #eef4f7; text-decoration: none; }
.paginacao-lista .atual span {
    background: var(--navy);
    border-color: var(--navy);
    color: white;
    font-weight: 700;
}
.paginacao-lista .desativado span { color: var(--muted); background: #f3f0ea; }
.vazio { padding: 1rem; color: var(--muted); }
.texto { max-width: 42rem; }
.botao {
    display: inline-flex;
    align-items: center;
    background: var(--navy);
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    padding: .7rem 1rem;
    font-weight: 600;
}
.botao:hover { text-decoration: none; opacity: .92; }
.acoes { display: flex; gap: .8rem; align-items: center; }
.acoes form { margin: 0; }
.link-perigo {
    background: none;
    border: 0;
    padding: 0;
    color: var(--late);
    cursor: pointer;
    font: inherit;
}
.contexto, .contexto-fixo {
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    padding: .7rem .8rem;
    font-size: .82rem;
}
.contexto label { color: #d7e6ef; }
.contexto select {
    margin-top: .35rem;
    width: 100%;
    background: #0d334c;
    color: white;
    border-color: rgba(255,255,255,.25);
}
.contexto-fixo { margin: 0; color: #d7e6ef; }
.erro-box { background: #fde8e6; border-color: #f2c4bf; color: var(--late); }

@media (max-width: 960px) {
    body.menu-bloqueado { overflow: hidden; }
    .app {
        display: flex;
        flex-direction: column;
    }
    .menu-topo {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 30;
        flex-shrink: 0;
        align-items: center;
        gap: .75rem;
        padding: .7rem 1rem;
        background: var(--navy-dark);
        color: white;
        box-shadow: 0 2px 12px rgba(0,0,0,.18);
    }
    .barra-conta { display: none; }
    .conta-slot-mobile { display: block; }
    .menu-topo .conta-botao { border-color: rgba(255,255,255,.45); }
    .menu-topo strong { font-size: .95rem; }
    .menu-topo-logo { height: 32px; width: auto; object-fit: contain; }
    .menu-toggle {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 42px;
        height: 42px;
        padding: .55rem;
        border: 1px solid rgba(255,255,255,.28);
        border-radius: 10px;
        background: rgba(255,255,255,.08);
        cursor: pointer;
    }
    .menu-toggle span {
        display: block;
        height: 2px;
        width: 100%;
        background: white;
        border-radius: 99px;
        transition: transform .2s ease, opacity .2s ease;
    }
    .app.menu-aberto .menu-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .app.menu-aberto .menu-toggle span:nth-child(2) { opacity: 0; }
    .app.menu-aberto .menu-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
    .menu-fundo {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 35;
        background: rgba(8, 22, 32, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }
    .app.menu-aberto .menu-fundo {
        opacity: 1;
        pointer-events: auto;
    }
    .menu-fundo[hidden] { display: none !important; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        bottom: 0;
        z-index: 40;
        flex: none;
        width: 88%;
        max-width: 300px;
        height: 100%;
        transform: translate3d(-100%, 0, 0);
        transition: transform .22s ease;
        overflow-y: auto;
        box-shadow: 8px 0 24px rgba(0,0,0,.25);
    }
    .app.menu-aberto .sidebar { transform: translate3d(0, 0, 0); }
    .menu-fechar {
        display: inline-flex;
        margin-top: .2rem;
        background: rgba(255,255,255,.12);
        border: 1px solid rgba(255,255,255,.3);
        color: white;
        border-radius: 8px;
        padding: .3rem .6rem;
        cursor: pointer;
        font-size: .8rem;
    }
    .app-main { min-height: 0; flex: 1; }
    .conteudo { padding: 1.1rem 1rem 1.5rem; }
    .form-grid, .form-grid.compact, .filtros, .anos { grid-template-columns: 1fr; }
    .span-2, .form-grid.compact .span-2 { grid-column: auto; }
}
