* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background: #f5f5f5;
    color: #2f241d;
    width: 100%;
}

body.nav-open {
    overflow: hidden;
}

img,
canvas,
svg {
    max-width: 100%;
}

.app-shell {
    min-height: 100vh;
    overflow-x: clip;
    width: 100%;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 220px;
    height: 100vh;
    height: 100dvh;
    background: #3c2500;
    color: #fff;
    transition: width 0.3s ease, transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1035;
}

.sidebar.collapsed {
    width: 70px;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.logo {
    display: block;
    width: 120px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.sidebar .logo {
    width: 100%;
    margin-bottom: 20px;
    border-radius: 10px;
}

.sidebar.collapsed .logo {
    width: 40px;
}

.menu {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px;
    gap: 8px;
}

.menu::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    width: 100%;
    color: #ccc;
    text-decoration: none;
    border-radius: 8px;
    transition: 0.3s;
    box-sizing: border-box;
}

.menu-btn:hover {
    background: #5f3d25;
    color: #fff;
}

.menu-btn.active {
    background: #523520;
    color: #fff;
    border-left: 4px solid #e8be3f;
}

.menu-btn i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.text {
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .text {
    display: none;
}

.sidebar.collapsed .menu-btn {
    justify-content: center;
    padding: 12px 0;
}

.logout {
    margin-top: 20px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.logout-form {
    margin: 0;
}

.footer-text {
    margin-top: auto;
    flex-shrink: 0;
    font-size: 11px;
    color: #aaa;
    text-align: center;
    padding: 15px 10px;
    line-height: 1.4;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .footer-text {
    opacity: 0;
    pointer-events: none;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #4a3728;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.menu-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.88);
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 12, 8, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1030;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.toast-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 260px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 15px;
    border-radius: 8px;
    color: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 1s ease;
}

.toast-alert.fade-out {
    opacity: 0;
    pointer-events: none;
}

.toast-alert:hover {
    opacity: 1;
}

.toast-alert.success { background: #28a745; }
.toast-alert.danger { background: #dc3545; }
.toast-alert.warning { background: #ffc107; color: #000; }
.toast-alert.info { background: #0d6efd; }

.toast-alert .progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    animation: progress 5s linear forwards;
}

@keyframes progress {
    from { width: 100%; }
    to { width: 0%; }
}

.main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    padding: 30px 30px 30px 250px;
    transition: padding-left 0.3s ease;
    overflow-x: hidden;
}

.sidebar.collapsed ~ .main {
    padding-left: 100px;
}

h1,
h2 {
    color: #4a3728;
}

.topbar {
    margin-bottom: 24px;
}

.conteudo {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    transition: 0.2s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12);
}

button,
.btn-brown {
    background: #6b4f3b;
    color: #fff;
}

.btn-outline-brown {
    border: 1px solid #6b4f3b;
    background: none;
    color: #6b4f3b;
}

.btn-outline-brown:hover,
.btn-brown:hover {
    background: #4a3728;
    color: #fff;
}

.btn-novo {
    margin-bottom: 20px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #6b4f3b;
}

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

label {
    margin-top: 10px;
    margin-bottom: 5px;
    color: #6b4f3b;
}

.form-container {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 600px;
}

.tabelas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.tabela-box {
    min-width: 0;
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

th {
    color: #4a3728;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.container-financeiro {
    max-width: 1200px;
    margin: 0 auto;
}

.cards-financeiro {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.card-fin {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.card-fin h3 {
    font-size: 13px;
    color: #777;
}

.card-fin p {
    font-size: clamp(20px, 2.2vw, 24px);
    font-weight: bold;
    color: #4a3728;
    overflow-wrap: anywhere;
}

.graficos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.grafico-box {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.grafico-conteudo {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.grafico-titulo {
    margin-bottom: 16px;
    font-size: 18px;
    color: #4a3728;
    font-weight: 700;
}

.grafico-canvas {
    position: relative;
    width: 100%;
    height: 300px;
}

.grafico-canvas canvas {
    display: block;
    max-width: 100%;
    width: 100% !important;
    height: 100% !important;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #301e01, #3c2500, rgb(94, 40, 2));
}

.login-wrapper {
    min-height: 100vh;
}

.login-box {
    background: #fff;
    padding: 35px;
    width: 100%;
    max-width: 380px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.login-box .logo {
    width: 200px;
    margin-bottom: 20px;
    background: #fff;
    padding: 8px;
    border-radius: 10px;
}

.login-box h2 {
    margin-bottom: 20px;
    color: #4a3728;
    font-weight: bold;
}

.login-box .form-control {
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
}

.login-box .form-control:focus {
    border-color: #6b4f3b;
    box-shadow: 0 0 0 0.2rem rgba(107, 79, 59, 0.25);
}

.login-box .btn-login {
    background: #3c2500;
    color: #fff;
    border-radius: 8px;
    padding: 10px;
    font-weight: bold;
    transition: 0.2s;
}

.login-box .btn-login:hover {
    background: #4a3728;
}

#mensagem {
    margin-top: 10px;
    font-size: 14px;
}

.pagination .page-link {
    color: #6b4f3b;
    border: 1px solid #6b4f3b;
    background-color: transparent;
    transition: 0.2s;
}

.pagination .page-link:hover {
    background-color: #6b4f3b;
    color: #fff;
    border-color: #6b4f3b;
}

.pagination .page-item.active .page-link {
    background-color: #6b4f3b;
    border-color: #6b4f3b;
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #c0b3a8;
    border-color: #c0b3a8;
    background-color: #f8f5f2;
}

.header-mobile {
    display: none;
}

.form-control {
    border: 1px solid #e0e0e0;
    padding: 10px;
    transition: 0.2s;
}

.form-control:focus {
    border-color: #8b5e3c;
    box-shadow: 0 0 0 0.2rem rgba(139, 94, 60, 0.2);
}

.form-select {
    border: 1px solid #e0e0e0;
}

.modal-title {
    letter-spacing: 0.5px;
}

.tabela-box:empty {
    display: none;
}

.estoque-actions {
    justify-content: flex-end;
}

.estoque-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 992px) {
    .cards-financeiro {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

@media (max-width: 768px) {
    .header-mobile {
        position: sticky;
        top: 0;
        z-index: 1025;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
        padding: 10px 14px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    .logo-header {
        height: 52px;
        width: auto;
        object-fit: contain;
        margin-left: auto;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        width: min(280px, calc(100vw - 40px));
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    }

    .sidebar.collapsed {
        width: min(280px, calc(100vw - 40px));
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar .text,
    .sidebar .footer-text {
        display: block;
        opacity: 1;
    }

    .sidebar .menu-btn {
        justify-content: flex-start;
        padding: 12px;
    }

    .main,
    .sidebar.collapsed ~ .main {
        margin-left: 0;
        width: 100%;
        min-width: 0;
        padding: 18px 14px 24px;
    }

    .topbar,
    .d-flex.justify-content-between.align-items-center.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-3 {
        align-items: stretch !important;
        gap: 12px;
    }

    .topbar > *,
    .d-flex.justify-content-between.align-items-center.mb-4 > *,
    .d-flex.justify-content-between.align-items-center.mb-3 > * {
        max-width: 100%;
    }

    .cards-financeiro {
        grid-template-columns: 1fr;
    }

    .grafico-canvas {
        height: 240px;
    }

    .conteudo,
    .tabela-box,
    .card-fin,
    .grafico-box {
        padding: 16px;
    }

    .modal-content {
        padding: 16px;
    }

    .modal-dialog {
        margin: 12px;
    }

    .toast-alert {
        top: 72px;
        right: 12px;
        left: 12px;
        min-width: 0;
        max-width: none;
    }

    .estoque-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 576px) {
    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    .main,
    .sidebar.collapsed ~ .main {
        padding: 16px 12px 24px;
    }

    .card-fin p {
        font-size: 20px;
    }

    .grafico-titulo {
        font-size: 16px;
    }

    .btn,
    button,
    .form-control,
    .form-select {
        width: 100%;
    }

    .d-flex.gap-2.flex-wrap.align-items-end > *,
    .d-flex.flex-wrap.gap-2.align-items-center > *,
    .d-flex.gap-2.flex-wrap.align-items-center > * {
        width: 100%;
        max-width: 100% !important;
    }

    .table-responsive .table {
        min-width: 620px;
    }

    .estoque-actions {
        gap: 10px !important;
    }

    .estoque-action-btn {
        width: 46px;
        height: 46px;
        padding: 0;
        justify-content: center;
        border-radius: 12px;
        flex: 0 0 auto;
        font-size: 0;
    }

    .estoque-action-btn i {
        margin: 0;
        font-size: 18px;
    }

    .estoque-action-label {
        display: none;
    }
}
