/* ==========================================================================
   Emissor NFS-e — tokens de design
   Paleta: azul-marinho (confiança/fiscal) + azul de ação + estados semânticos
   ========================================================================== */
:root {
    --navy-950: #0f1b30;
    --navy-900: #16233d;
    --navy-800: #1e2d4d;
    --blue-600: #2454c7;
    --blue-700: #1d3f9e;
    --blue-50: #eaf0fd;

    --bg: #f2f4f8;
    --surface: #ffffff;
    --text: #16213a;
    --text-soft: #5b6577;
    --text-faint: #94a0b4;
    --border: #e3e7ef;

    --sucesso-bg: #e3f6ea; --sucesso-texto: #116631; --sucesso-dot: #22a35b;
    --erro-bg: #fdeaea;    --erro-texto: #9c1f1f;    --erro-dot: #d33a3a;
    --aviso-bg: #fff4e0;   --aviso-texto: #8a5a00;   --aviso-dot: #e0a020;
    --neutro-bg: #eceef2;  --neutro-texto: #454e60;  --neutro-dot: #8891a3;

    --raio-sm: 6px;
    --raio-md: 10px;
    --raio-lg: 14px;
    --sombra-card: 0 1px 2px rgba(16,27,48,0.04), 0 4px 14px rgba(16,27,48,0.06);
    --sombra-hover: 0 6px 20px rgba(16,27,48,0.10);
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barra de destaque + navegação ---------- */
.faixa-topo {
    height: 3px;
    background: linear-gradient(90deg, var(--blue-600), #4f7fe0 55%, #7aa5ec);
}

.topnav {
    background: var(--navy-900);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 58px;
}
.topnav .brand {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.01em;
    margin-right: 22px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.topnav .brand svg { flex-shrink: 0; }
.topnav a {
    color: #a9b6cc;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--raio-sm);
    transition: background 0.15s ease, color 0.15s ease;
}
.topnav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.topnav a.ativo { color: #fff; background: rgba(255,255,255,0.10); }

.link-sair {
    background: none; border: 1px solid #384865; color: #a9b6cc;
    padding: 7px 14px; border-radius: var(--raio-sm); cursor: pointer; font-size: 13px;
    transition: all 0.15s ease;
}
.link-sair:hover { color: #fff; border-color: #64749a; background: rgba(255,255,255,0.05); }
.usuario-logado {
    color: #7c8aa5;
    font-size: 13px;
    margin-left: auto;
    margin-right: 6px;
}

/* ---------- Layout geral ---------- */
.container {
    max-width: 960px;
    margin: 32px auto;
    padding: 0 20px 48px;
}
h1 { font-size: 23px; font-weight: 700; margin: 0 0 18px; letter-spacing: -0.01em; }
h2 { font-weight: 700; }
h3 { font-weight: 600; }

/* ---------- Cards do painel inicial ---------- */
.cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.card {
    background: var(--surface);
    border-radius: var(--raio-md);
    padding: 18px 22px;
    min-width: 140px;
    box-shadow: var(--sombra-card);
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: var(--sombra-hover); transform: translateY(-1px); }
.card .numero { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.card .rotulo { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* ---------- Botões ---------- */
.botao {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 16px;
    border-radius: var(--raio-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-right: 8px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.botao:hover { background: #f7f9fc; border-color: #cdd5e2; }
.botao:active { transform: translateY(1px); }
.botao.destaque {
    background: var(--blue-600); color: #fff; border-color: var(--blue-600);
}
.botao.destaque:hover { background: var(--blue-700); border-color: var(--blue-700); }

/* ---------- Tabelas ---------- */
.tabela {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--raio-md);
    overflow: hidden;
    margin: 14px 0;
    box-shadow: var(--sombra-card);
    border: 1px solid var(--border);
}
.tabela th, .tabela td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.tabela th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}
.tabela tbody tr:nth-child(even) { background: #fafbfd; }
.tabela tbody tr:hover { background: var(--blue-50); }
.tabela tbody tr:last-child td { border-bottom: none; }

.acoes { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.acoes a, .acoes button.link-perigo, .acoes .texto-desabilitado {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 13px; margin: 0;
}
.acoes svg { flex-shrink: 0; }
.acoes form { display: inline-flex; }

.texto-desabilitado {
    color: var(--text-faint);
    cursor: not-allowed;
}

/* ---------- Avisos / mensagens ---------- */
.caixa-aviso {
    background: var(--aviso-bg);
    color: var(--aviso-texto);
    border: 1px solid #f3d8a0;
    border-radius: var(--raio-md);
    padding: 13px 16px;
    margin-bottom: 18px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    animation: aviso-entrada 0.2s ease;
}
.caixa-aviso p { margin: 0; }
.caixa-aviso .fechar-aviso {
    background: none; border: none; cursor: pointer;
    color: var(--aviso-texto); opacity: 0.6; font-size: 16px; line-height: 1;
    padding: 2px 4px;
}
.caixa-aviso .fechar-aviso:hover { opacity: 1; }
@keyframes aviso-entrada {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.link-perigo {
    background: none; border: none; color: var(--erro-dot); cursor: pointer;
    font-size: 13px; padding: 0;
}
.link-perigo:hover { color: #a52222; text-decoration: underline; }
.erro { color: var(--erro-texto); font-size: 13px; }

/* ---------- Status (badges com indicador) ---------- */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.status::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.status-pendente { background: var(--aviso-bg); color: var(--aviso-texto); }
.status-pendente::before { background: var(--aviso-dot); }
.status-emitida { background: var(--sucesso-bg); color: var(--sucesso-texto); }
.status-emitida::before { background: var(--sucesso-dot); }
.status-erro { background: var(--erro-bg); color: var(--erro-texto); }
.status-erro::before { background: var(--erro-dot); }
.status-pulada { background: var(--neutro-bg); color: var(--neutro-texto); }
.status-pulada::before { background: var(--neutro-dot); }
.status-cancelamento_pendente { background: var(--aviso-bg); color: var(--aviso-texto); }
.status-cancelamento_pendente::before { background: var(--aviso-dot); }
.status-cancelada { background: var(--neutro-bg); color: var(--neutro-texto); }
.status-cancelada::before { background: var(--erro-dot); }

/* ---------- Formulários ---------- */
.form {
    display: flex; flex-direction: column; gap: 15px; max-width: 480px;
    background: var(--surface); padding: 22px; border-radius: var(--raio-md);
    box-shadow: var(--sombra-card); border: 1px solid var(--border);
}
.form label { display: flex; flex-direction: column; font-size: 13px; gap: 6px; color: var(--text-soft); font-weight: 500; }
.form input, .form select, .form textarea {
    padding: 10px 11px; border: 1px solid #d3d9e3; border-radius: var(--raio-sm);
    font-size: 14px; font-family: inherit; color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--blue-600);
    box-shadow: 0 0 0 3px var(--blue-50);
}
.form a { color: var(--text-soft); font-size: 13px; text-decoration: none; }
.form a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Log de execução ---------- */
.log {
    background: var(--navy-950);
    color: #b7f5d8;
    padding: 16px;
    border-radius: var(--raio-md);
    height: 480px;
    overflow-y: auto;
    font-size: 13px;
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    white-space: pre-wrap;
    border: 1px solid var(--navy-800);
}
.layout-execucao {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}
.coluna-log, .coluna-tela-remota {
    flex: 1 1 420px;
    min-width: 320px;
}
.coluna-log h3, .coluna-tela-remota h3 {
    font-size: 14px;
    margin: 0 0 8px 0;
    color: var(--text-soft);
}
.link-discreto {
    font-size: 12px;
    font-weight: normal;
    color: var(--blue-600);
}
.iframe-novnc {
    width: 100%;
    height: 480px;
    border: 1px solid var(--border);
    border-radius: var(--raio-md);
    background: #000;
}
.caixa-acao {
    background: #fff7ed;
    border: 1px solid #fdba74;
    padding: 14px 16px;
    border-radius: var(--raio-md);
    margin-bottom: 14px;
}
.caixa-acao button { margin-right: 8px; margin-top: 8px; }

/* ---------- Relatório mensal ---------- */
.card-mes {
    background: var(--surface);
    border-radius: var(--raio-md);
    padding: 20px 22px;
    margin-bottom: 18px;
    box-shadow: var(--sombra-card);
    border: 1px solid var(--border);
}
.card-mes-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-mes-cabecalho h2 {
    font-size: 17px;
    margin: 0;
    text-transform: capitalize;
}
.card-mes-resumo {
    display: flex;
    gap: 18px;
    font-size: 14px;
    color: var(--text-soft);
}
.card-mes-resumo strong { color: var(--text); }
.subtitulo-mes {
    font-size: 12.5px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin: 18px 0 8px 0;
}

/* ---------- Paginação ---------- */
.paginacao {
    font-size: 13.5px;
    color: var(--text-soft);
}
.paginacao a {
    color: var(--blue-600);
    text-decoration: none;
    font-weight: 500;
}
.paginacao a:hover { text-decoration: underline; }

/* ---------- Responsividade básica ---------- */
@media (max-width: 720px) {
    .topnav { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 2px; }
    .usuario-logado { margin-left: 0; order: 10; width: 100%; margin-top: 4px; }
    .container { padding: 0 14px 40px; margin: 20px auto; }
    .tabela, .tabela thead { display: block; }
    .tabela thead tr { position: absolute; top: -9999px; left: -9999px; }
    .tabela tbody tr {
        display: block; margin-bottom: 12px; border: 1px solid var(--border);
        border-radius: var(--raio-md); padding: 6px 0;
    }
    .tabela tbody td {
        display: flex; justify-content: space-between; gap: 12px;
        border-bottom: 1px solid #f0f2f6; text-align: right;
    }
    .tabela tbody td::before {
        content: attr(data-rotulo); font-weight: 600; color: var(--text-soft);
        text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
    }
    .tabela tbody td:last-child { border-bottom: none; }
}
