/* ============================================================
   MSE GESTÃO DE RESÍDUOS — STYLESHEET UNIFICADO
   Versão limpa, sem duplicações, visual moderno
   ============================================================ */

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

html, body {
    height: 100%;
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #222;
    background: #f0f2f5;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: linear-gradient(180deg, #7A0000 0%, #5a0000 100%);
    color: #fff;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    padding: 4px 4px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    margin-bottom: 16px;
    text-align: center;
}

.logo .logo-img {
    display: block;
    margin: 4px auto 10px;
    width: 140px;
    max-width: 80%;
    height: auto;
    filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
    transition: transform 0.25s ease, filter 0.25s ease;
}

.logo:hover .logo-img {
    transform: scale(1.04);
    filter: brightness(0) invert(1) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.logo h2 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
}

.logo span {
    font-size: 11px;
    opacity: 0.8;
    display: block;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #fff;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13.5px;
    transition: background 0.18s, color 0.18s, padding-left 0.18s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu a:hover,
.menu a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    padding-left: 18px;
}

.menu hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.12);
    margin: 8px 0;
}

/* ============================================================
   CONTENT
   ============================================================ */

.content {
    flex: 1;
    padding: 30px 36px;
    background: #f0f2f5;
    min-height: 100vh;
    overflow-x: auto;
}

.content h1 {
    font-size: 22px;
    font-weight: 700;
    color: #7A0000;
    margin-bottom: 24px;
    border-left: 4px solid #7A0000;
    padding-left: 12px;
}

.content h2 {
    font-size: 16px;
    font-weight: 600;
    color: #444;
    margin: 24px 0 12px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: #fff;
    border-radius: 10px;
    padding: 22px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    margin-bottom: 22px;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 15px;
    color: #555;
    font-weight: 600;
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */

form,
.form-padrao {
    background: #fff;
    border-radius: 10px;
    padding: 22px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    max-width: 640px;
    margin-bottom: 24px;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-top: 14px;
    margin-bottom: 5px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    background: #fafafa;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #7A0000;
    background: #fff;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ============================================================
   BOTÕES
   ============================================================ */

button,
.btn {
    cursor: pointer;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    transition: opacity 0.18s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

button:hover,
.btn:hover {
    opacity: 0.88;
}

button:active,
.btn:active {
    transform: scale(0.97);
}

.btn-salvar,
.btn-vermelho,
button[type="submit"] {
    background: #7A0000;
    color: #fff;
    margin-top: 16px;
}

.btn-adicionar {
    background: #2ecc71;
    color: #fff;
    margin-top: 8px;
    margin-bottom: 4px;
}

.btn-editar {
    background: #3498db;
    color: #fff;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 5px;
}

.btn-inativar {
    background: #f39c12;
    color: #fff;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 5px;
}

.btn-excluir {
    background: #e74c3c;
    color: #fff;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 5px;
}

.btn-reativar {
    background: #27ae60;
    color: #fff;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 5px;
}

.btn-pdf {
    background: #c0392b;
    color: #fff;
}

.btn-excel {
    background: #27ae60;
    color: #fff;
}

.acoes {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* ============================================================
   TABELAS
   ============================================================ */

table,
.tabela {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    margin-top: 8px;
    font-size: 13px;
}

table th,
.tabela th {
    background: #7A0000;
    color: #fff;
    padding: 11px 12px;
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

table td,
.tabela td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

table tr:last-child td,
.tabela tr:last-child td {
    border-bottom: none;
}

table tr:hover td,
.tabela tr:hover td {
    background: #fdf5f5;
}

/* ============================================================
   MENSAGENS / ALERTAS
   ============================================================ */

#mensagem,
.mensagem-sucesso {
    margin-top: 12px;
    font-weight: 600;
    font-size: 13px;
    color: green;
}

.mensagem-erro {
    color: #e74c3c;
    font-weight: 600;
    font-size: 13px;
    margin-top: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-pendente   { background: #fff3cd; color: #856404; }
.badge-andamento  { background: #cce5ff; color: #004085; }
.badge-concluido  { background: #d4edda; color: #155724; }
.badge-recusado   { background: #f8d7da; color: #721c24; }
.badge-ativo      { background: #d4edda; color: #155724; }
.badge-inativo    { background: #f8d7da; color: #721c24; }

/* ============================================================
   FILTROS
   ============================================================ */

.filtros {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: #fff;
    padding: 16px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.filtros .campo {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.filtros label {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.filtros select,
.filtros input[type="date"],
.filtros input[type="text"] {
    height: 36px;
    padding: 5px 10px;
    font-size: 13px;
    min-width: 130px;
}

.filtros button {
    height: 36px;
    padding: 0 16px;
    margin-top: 0;
}

/* ============================================================
   GRID UTILITÁRIOS
   ============================================================ */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.flex-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

/* ============================================================
   GRÁFICOS
   ============================================================ */

.graficos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
}

.grafico-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.grafico-card h3 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: #444;
}

.grafico-container {
    position: relative;
    width: 100%;
    height: 340px;
}

.grafico-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   HOME / DASHBOARD
   ============================================================ */

.home-bg {
    position: relative;
    background-image: url("https://i.postimg.cc/4dqNfRLZ/image-(90).jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    padding: 30px 36px;
}

.home-bg::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.6);
    z-index: 0;
}

.home-bg > * {
    position: relative;
    z-index: 1;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
    margin-top: 12px;
}

.home-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow 0.2s;
}

.home-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.home-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #7A0000;
    border-bottom: 2px solid #f0e6e6;
    padding-bottom: 8px;
}

.home-card .subtitulo {
    font-size: 12px;
    color: #888;
    margin-top: -10px;
}

.home-lista-saldo {
    font-size: 13px;
}

.home-lista-saldo .saldo-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #f5f5f5;
}

.home-lista-saldo .saldo-item:last-child {
    border-bottom: none;
}

.home-lista-saldo .saldo-nome {
    color: #555;
}

.home-lista-saldo .saldo-valor {
    font-weight: 700;
    color: #222;
}

.home-grafico-container {
    position: relative;
    width: 100%;
    height: 200px;
}

.home-grafico-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.home-sem-dados {
    text-align: center;
    color: #aaa;
    font-size: 13px;
    padding: 10px 0;
}

/* ============================================================
   SALDO DE CAÇAMBAS — CARDS
   ============================================================ */

.saldo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.saldo-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    min-width: 220px;
    flex: 1;
    max-width: 280px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.saldo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 22px rgba(0,0,0,0.15);
}

.saldo-card-titulo {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.saldo-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.saldo-mini {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
}

.saldo-mini-entrada  { background: #eef2ff; }
.saldo-mini-saida    { background: #fff4e6; }

.saldo-mini .label {
    color: #888;
    margin-bottom: 4px;
    font-size: 11px;
}

.saldo-mini .valor {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.saldo-atual {
    background: #e6fff0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.saldo-atual .label {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
}

.saldo-atual .valor {
    font-size: 24px;
    font-weight: 800;
    color: #27ae60;
}

.saldo-atual.critico .valor {
    color: #e74c3c;
}

/* ============================================================
   RESÍDUOS — CADASTRO FORNECEDOR
   ============================================================ */

.lista-residuos {
    margin-bottom: 8px;
}

.residuo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.residuo-item select.residuoNome {
    flex: 3;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
}

.residuo-item input.residuoValor {
    width: 160px;
    min-width: 140px;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
}

.residuo-item .btn-excluir-residuo {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 13px;
}

/* ============================================================
   STATUS SELECT (SOLICITAÇÕES)
   ============================================================ */

.status-select {
    padding: 5px 8px;
    border-radius: 5px;
    border: 1.5px solid #ccc;
    font-size: 12px;
    cursor: pointer;
}

.status-PENDENTE    { background: #fff3cd; color: #856404; }
.status-EM-ANDAMENTO { background: #cce5ff; color: #004085; }
.status-CONCLUIDO   { background: #d4edda; color: #155724; }
.status-RECUSADO    { background: #f8d7da; color: #721c24; }

/* ============================================================
   BOTÕES DE AÇÃO (tabelas)
   ============================================================ */

.btn-acao {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.18s;
}

.btn-acao:hover { opacity: 0.8; }

/* ============================================================
   LOADING STATE
   ============================================================ */

.loading {
    text-align: center;
    color: #aaa;
    padding: 20px;
    font-style: italic;
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */

@media (max-width: 900px) {
    .sidebar {
        width: 220px;
        min-width: 220px;
        padding: 16px 10px;
    }

    .content,
    .home-bg {
        padding: 20px 18px;
    }

    .graficos-grid {
        grid-template-columns: 1fr;
    }

    .home-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: static;
        height: auto;
        overflow: visible;
    }

    .filtros {
        flex-direction: column;
    }

    .grid-4 {
        grid-template-columns: 1fr 1fr;
    }

    table {
        font-size: 12px;
    }

    table th, table td {
        padding: 8px 8px;
    }
}

/* ============================================================
   UTILIDADES EXTRAS
   ============================================================ */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #888; }
.text-danger { color: #e74c3c; }
.text-success { color: #27ae60; }
.font-bold   { font-weight: 700; }
.w-full      { width: 100%; }
.d-flex      { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   BADGE DE UNIDADE (exibição da unidade de medida)
   ============================================================ */

.badge-unidade {
    display: inline-block;
    background: #eef3ff;
    color: #2c5fbd;
    border: 1px solid #c5d5f5;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* ============================================================
   RESÍDUO ITEM — FORNECEDOR (resíduo + unidade + valor)
   ============================================================ */

.residuo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
}

.residuo-item select.residuoNome {
    flex: 2;
    min-width: 160px;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
}

.residuo-item select.residuoDescricao {
    flex: 2;
    min-width: 150px;
    max-width: 210px;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
}

.residuo-item input.residuoValor {
    width: 130px;
    min-width: 110px;
    height: 38px;
    padding: 6px 10px;
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
}

.residuo-item .btn-excluir-residuo {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 13px;
}

/* ============================================================
   SALDO CARD — unidade
   ============================================================ */

.saldo-card-unidade {
    font-size: 11px;
    color: #2c5fbd;
    background: #eef3ff;
    border: 1px solid #c5d5f5;
    border-radius: 12px;
    padding: 2px 10px;
    display: inline-block;
    margin-bottom: 12px;
    font-weight: 700;
}

/* ============================================================
   CÁLCULO DE VALOR (Retirada)
   ============================================================ */

.calculo-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f0faf0;
    border: 1.5px solid #a3d9a5;
    border-radius: 8px;
    font-size: 14px;
    flex-wrap: wrap;
}

.calculo-preview .calculo-total {
    font-size: 18px;
    font-weight: 800;
    color: #1a7a2e;
}

.texto-aviso {
    font-size: 12px;
    color: #856404;
    background: #fff3cd;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
    margin-top: 6px;
}

/* ============================================================
   TOTAIS DO RELATÓRIO
   ============================================================ */

.totais-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.total-item {
    background: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    min-width: 160px;
    text-align: center;
    border-top: 3px solid #7A0000;
}

.total-item.destaque {
    border-top-color: #27ae60;
    background: #f0fff4;
}

.total-item .total-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 6px;
}

.total-item .total-valor {
    font-size: 20px;
    font-weight: 800;
    color: #333;
}

.total-item.destaque .total-valor {
    color: #1a7a2e;
}

/* ============================================================
   CARDS DE TOTAIS (Gráficos)
   ============================================================ */

.cards-totais-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
}

.card-total {
    background: #fff;
    border-radius: 10px;
    padding: 16px 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    min-width: 160px;
    border-left: 4px solid #7A0000;
}

.card-total.destaque {
    border-left-color: #27ae60;
    background: #f0fff4;
}

.card-total-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.card-total-valor {
    font-size: 22px;
    font-weight: 800;
    color: #333;
}

.card-total.destaque .card-total-valor {
    color: #1a7a2e;
}

/* ============================================================
   HOME DASHBOARD — saldo crítico
   ============================================================ */

.saldo-item.saldo-critico .saldo-valor {
    color: #e74c3c;
    font-weight: 800;
}

/* ============================================================
   RESPONSIVIDADE — residuo-item no mobile
   ============================================================ */

@media (max-width: 640px) {
    .residuo-item {
        flex-wrap: wrap;
    }
    .residuo-item select.residuoNome {
        flex: 1 1 100%;
    }
    .residuo-item select.residuoDescricao {
        flex: 1 1 60%;
        max-width: none;
    }
    .residuo-item input.residuoValor {
        flex: 1 1 35%;
    }
}
