:root {
    color-scheme: light;
    --cor-fundo: #f5f6f8;
    --cor-texto: #1f2430;
    --cor-borda: #d7dbe2;
    --cor-primaria: #2f6fed;
    --cor-primaria-hover: #2559c4;
    --cor-sidebar: #1f2733;
    --cor-sidebar-texto: #e5e9f0;
    --cor-sidebar-ativo: #2f6fed;
    --cor-erro-fundo: #fdecea;
    --cor-erro-texto: #b3261e;
    --cor-sucesso-fundo: #e8f5e9;
    --cor-sucesso-texto: #1b5e20;
    --cor-aviso-fundo: #fff4e5;
    --cor-aviso-texto: #8a4b00;
    --cor-card: #ffffff;
    --sombra-card: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --sombra-card-hover: 0 6px 16px rgba(15, 23, 42, 0.1), 0 2px 4px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --cor-fundo: #14171c;
        --cor-texto: #e5e9f0;
        --cor-borda: #333a45;
        --cor-sidebar: #10141a;
        --cor-erro-fundo: #3a1f1f;
        --cor-erro-texto: #f2a09b;
        --cor-sucesso-fundo: #1c3320;
        --cor-sucesso-texto: #9be3a1;
        --cor-aviso-fundo: #3a2c12;
        --cor-aviso-texto: #f5c27a;
        --cor-card: #1a1f28;
        --sombra-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
        --sombra-card-hover: 0 6px 16px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --cor-fundo: #14171c;
    --cor-texto: #e5e9f0;
    --cor-borda: #333a45;
    --cor-sidebar: #10141a;
    --cor-erro-fundo: #3a1f1f;
    --cor-erro-texto: #f2a09b;
    --cor-sucesso-fundo: #1c3320;
    --cor-sucesso-texto: #9be3a1;
    --cor-aviso-fundo: #3a2c12;
    --cor-aviso-texto: #f5c27a;
    --cor-card: #1a1f28;
    --sombra-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --sombra-card-hover: 0 6px 16px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1 {
    font-size: 1.6rem;
    margin-top: 0;
}

h2 {
    font-size: 1.2rem;
}

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--cor-sidebar);
    color: var(--cor-sidebar-texto);
}

.nav-header {
    padding: 1rem;
    font-weight: 600;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.nav-logo-link {
    display: block;
    color: var(--cor-sidebar-texto);
    text-decoration: none;
    min-width: 0;
    flex: 1;
}

.botao-tema {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: none;
    color: var(--cor-sidebar-texto);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.botao-tema:hover {
    background: rgba(255, 255, 255, 0.1);
}

.botao-tema svg {
    width: 16px;
    height: 16px;
}

.botao-tema .icone-sol {
    display: none;
}

:root[data-theme="dark"] .botao-tema .icone-lua {
    display: none;
}

:root[data-theme="dark"] .botao-tema .icone-sol {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .botao-tema .icone-lua {
        display: none;
    }

    :root:not([data-theme="light"]) .botao-tema .icone-sol {
        display: block;
    }
}

.nav-logo {
    max-width: 100%;
    max-height: 88px;
    display: block;
}

nav.flex-column {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
}

.nav-item {
    padding: 0.1rem 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    color: var(--cor-sidebar-texto);
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
    background: var(--cor-sidebar-ativo);
    color: #fff;
}

.nav-usuario {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.nav-usuario span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-usuario form {
    margin: 0;
    flex-shrink: 0;
}

.nav-logout {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--cor-sidebar-texto);
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.nav-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--cor-card);
    border: 1px solid var(--cor-borda);
    border-top: 4px solid var(--cor-primaria);
    border-radius: 14px;
    padding: 2.25rem 2rem;
    box-shadow: var(--sombra-card);
    text-align: center;
}

.login-logo {
    max-width: 160px;
    max-height: 64px;
    margin: 0 auto 1rem;
    display: block;
}

.login-eyebrow {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cor-primaria);
    margin-bottom: 0.5rem;
}

.login-box h1 {
    margin-bottom: 0.25rem;
}

.login-box p {
    opacity: 0.7;
    font-size: 0.9rem;
}

.login-box form {
    text-align: left;
    margin-top: 1.5rem;
}

.login-box input {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--cor-borda);
    border-radius: 8px;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-box input:focus {
    outline: none;
    border-color: var(--cor-primaria);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.login-box .btn-primary {
    width: 100%;
    margin-top: 0.25rem;
}

main {
    flex: 1;
    min-width: 0;
}

.content {
    max-width: 1200px;
    padding: 2rem;
}

.cabecalho-pagina {
    margin-bottom: 1.5rem;
}

.cabecalho-eyebrow {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cor-primaria);
    margin-bottom: 0.35rem;
}

.cabecalho-pagina h1 {
    margin-bottom: 0.25rem;
}

.cabecalho-subtitulo {
    margin: 0;
    opacity: 0.7;
    font-size: 0.95rem;
}

.painel {
    background: var(--cor-card);
    border: 1px solid var(--cor-borda);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--sombra-card);
    margin-bottom: 1.5rem;
}

.painel h2 {
    margin-top: 0;
}

.painel:last-child {
    margin-bottom: 0;
}

.upload-box {
    margin: 1rem 0;
}

.arquivo-info {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.arquivo-selecionado {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.arquivo-selecionado .arquivo-info {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.arquivo-miniatura {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--cor-borda);
}

.arquivo-miniatura-pdf {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #d1453b;
    background: rgba(209, 69, 59, 0.08);
}

.arquivo-miniatura-pdf svg {
    width: 26px;
    height: 26px;
}

.arquivo-miniatura-rotulo {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 2px dashed var(--cor-borda);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover {
    border-color: var(--cor-primaria);
    background: rgba(47, 111, 237, 0.04);
}

.dropzone-icone {
    width: 40px;
    height: 40px;
    color: var(--cor-primaria);
    opacity: 0.8;
}

.dropzone-texto {
    font-weight: 600;
}

.dropzone-subtexto {
    font-size: 0.8rem;
    opacity: 0.65;
}

.dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.secao-titulo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.secao-titulo h2 {
    margin: 0;
}

.secao-icone {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(47, 111, 237, 0.12);
    color: var(--cor-primaria);
}

.secao-icone svg {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--cor-primaria);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    cursor: pointer;
}

.btn-secundario {
    display: inline-block;
    background: transparent;
    color: var(--cor-primaria);
    border: 1px solid var(--cor-primaria);
    border-radius: 6px;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.btn-secundario:hover {
    background: rgba(47, 111, 237, 0.08);
}

.acoes-exportacao {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
    margin-bottom: 1rem;
}

.btn-primary:hover:not(:disabled) {
    background: var(--cor-primaria-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.campo-form {
    margin-bottom: 1rem;
    max-width: 480px;
}

.campo-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.campo-form input,
.campo-form select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--cor-borda);
    border-radius: 6px;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    font-size: 0.95rem;
}

.grupo-documento {
    border: 1px solid var(--cor-borda);
    border-radius: 10px;
    padding: 0.5rem 1.25rem 1rem;
    margin-bottom: 1.25rem;
    max-width: 480px;
    background: var(--cor-fundo);
}

.grupo-documento legend {
    font-weight: 600;
    padding: 0 0.4rem;
}

.tabela-resultado {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.tabela-resultado th,
.tabela-resultado td {
    text-align: left;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--cor-borda);
}

.tabela-resultado th {
    background: rgba(127, 127, 127, 0.08);
}

.tabela-resultado tbody tr:hover {
    background: rgba(127, 127, 127, 0.06);
}

.alert-erro,
.alert-sucesso {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

.alert-erro {
    background: var(--cor-erro-fundo);
    color: var(--cor-erro-texto);
}

.alert-sucesso {
    background: var(--cor-sucesso-fundo);
    color: var(--cor-sucesso-texto);
}

.alert-aviso {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background: var(--cor-aviso-fundo);
    color: var(--cor-aviso-texto);
}

.linha-acoes {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.linha-acoes > .btn-primary {
    text-decoration: none;
}

.busca-clientes {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 560px;
}

.busca-clientes input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--cor-borda);
    border-radius: 6px;
    background: var(--cor-fundo);
    color: var(--cor-texto);
    font-size: 0.95rem;
}

.leitura-cartao {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

/* InputFile transparente por cima do botão: o clique no botão estilizado abre o seletor de arquivo. */
.botao-arquivo {
    position: relative;
    overflow: hidden;
}

.botao-arquivo input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.botao-arquivo.desabilitado {
    opacity: 0.6;
    pointer-events: none;
}

.campo-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.campo-checkbox input {
    width: 1rem;
    height: 1rem;
}

.linha-botoes {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.titulo-formulario-usuario {
    margin-top: 2rem;
}

.texto-secundario {
    font-size: 0.85rem;
    opacity: 0.7;
}

.sem-quebra {
    white-space: nowrap;
}

.coluna-consumo {
    min-width: 160px;
}

.barra-consumo {
    height: 8px;
    border-radius: 4px;
    background: var(--cor-borda);
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.barra-consumo-preenchida {
    height: 100%;
    background: #1e9e5a;
}

.barra-consumo-preenchida.consumo-alerta {
    background: #e8892b;
}

.barra-consumo-preenchida.consumo-esgotado {
    background: #d1453b;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-ativo {
    background: rgba(30, 158, 90, 0.14);
    color: #1e9e5a;
}

.badge-inativo {
    background: rgba(127, 127, 127, 0.18);
    opacity: 0.85;
}

.link-botao {
    background: none;
    border: none;
    padding: 0;
    color: var(--cor-primaria);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

.observacao {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
    max-width: 640px;
}

.logo-preview {
    max-width: 240px;
    max-height: 80px;
}

.filtro-periodo {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filtro-periodo .campo-form {
    margin-bottom: 1rem;
    max-width: 200px;
}

.stat-cards {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    background: var(--cor-card);
    border: 1px solid var(--cor-borda);
    border-top: 4px solid var(--cor-borda);
    border-radius: 12px;
    padding: 1.1rem 1.4rem 1.3rem;
    min-width: 170px;
    flex: 1 1 170px;
    box-shadow: var(--sombra-card);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--sombra-card-hover);
}

.stat-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.stat-icone {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icone svg {
    width: 18px;
    height: 18px;
}

.stat-valor {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.6rem;
}

.stat-rotulo {
    font-size: 0.85rem;
    opacity: 0.75;
}

.stat-card-azul { border-top-color: #2f6fed; }
.stat-card-azul .stat-icone { background: rgba(47, 111, 237, 0.12); color: #2f6fed; }

.stat-card-verde { border-top-color: #1e9e5a; }
.stat-card-verde .stat-icone { background: rgba(30, 158, 90, 0.12); color: #1e9e5a; }

.stat-card-vermelho { border-top-color: #d1453b; }
.stat-card-vermelho .stat-icone { background: rgba(209, 69, 59, 0.12); color: #d1453b; }

.stat-card-roxo { border-top-color: #7c5cf0; }
.stat-card-roxo .stat-icone { background: rgba(124, 92, 240, 0.12); color: #7c5cf0; }

.stat-card-laranja { border-top-color: #e8892b; }
.stat-card-laranja .stat-icone { background: rgba(232, 137, 43, 0.12); color: #e8892b; }

.grafico-barras {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 150px;
    margin-top: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.barra-dia {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    min-width: 28px;
    height: 100%;
}

.barra {
    width: 18px;
    min-height: 2px;
    background: var(--cor-primaria);
    border-radius: 3px 3px 0 0;
}

.barra-rotulo {
    font-size: 0.7rem;
    opacity: 0.8;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .page {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .content {
        padding: 1rem;
    }
}
