:root {
    --azul: #1f3a5f;
    --azul-claro: #2e5a8f;
    --dourado: #b08d57;
    --cinza: #f4f5f7;
    --texto: #25303b;
    --borda: #dfe3e8;
    --ok: #1f7a4d;
    --erro: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--texto);
    background: var(--cinza);
    line-height: 1.5;
}

/* ---- Layout com sidebar ---- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
    width: 250px; flex-shrink: 0;
    background: #fff; border-right: 1px solid var(--borda);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; padding: .9rem .75rem;
}
.sidebar--admin { background: #0f172a; border-right-color: #1e293b; }

.sidebar-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; padding: .35rem .5rem .9rem; }
.brand-mark { color: var(--dourado); font-size: 1.15rem; }
.brand-name { font-size: 1rem; }
.brand-logo { height: 30px; max-width: 150px; object-fit: contain; }
.sidebar--admin .brand-name { color: #f1f5f9; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }

.nav-item {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .6rem; border-radius: 8px;
    color: #51606e; text-decoration: none; font-size: .92rem;
    border: none; background: transparent; width: 100%; cursor: pointer; font-family: inherit; text-align: left;
}
.nav-item .ico { flex-shrink: 0; color: #8a96a3; }
.nav-item:hover { background: #f3f5f7; color: var(--texto); }
.nav-item:hover .ico { color: #51606e; }
.nav-item.active { background: var(--cinza); color: var(--azul); font-weight: 600; }
.nav-item.active .ico { color: var(--azul); }

.sidebar--admin .nav-item { color: #cbd5e1; }
.sidebar--admin .nav-item .ico { color: #94a3b8; }
.sidebar--admin .nav-item:hover { background: #1e293b; color: #fff; }
.sidebar--admin .nav-item:hover .ico { color: #e2e8f0; }
.sidebar--admin .nav-item.active { background: #1e293b; color: #fff; }
.sidebar--admin .nav-item.active .ico { color: #fff; }

.sidebar-foot { border-top: 1px solid var(--borda); padding-top: .6rem; margin-top: .5rem; }
.sidebar--admin .sidebar-foot { border-top-color: #1e293b; }
.side-user { display: flex; align-items: center; gap: .55rem; padding: .35rem .6rem .5rem; font-size: .88rem; }
.side-user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--azul-claro); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.side-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar--admin .side-user-name { color: #cbd5e1; }
.nav-item--btn { color: #b42318; }
.nav-item--btn .ico { color: #b42318; }
.nav-item--btn:hover { background: #fdecea; color: #911c14; }
.nav-item--btn:hover .ico { color: #911c14; }
.sidebar--admin .nav-item--btn { color: #fca5a5; }
.sidebar--admin .nav-item--btn .ico { color: #fca5a5; }
.sidebar--admin .nav-item--btn:hover { background: #3f1d1d; color: #fecaca; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.mobile-bar { display: none; }
.nav-toggle { background: transparent; border: 1px solid var(--borda); color: var(--texto); font-size: 1.2rem; line-height: 1; padding: .3rem .55rem; border-radius: 6px; cursor: pointer; }
.nav-backdrop { display: none; }

/* ---- Mobile: sidebar off-canvas ---- */
@media (max-width: 860px) {
    .sidebar {
        position: fixed; top: 0; left: 0; z-index: 50;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: 0 10px 40px rgba(0,0,0,.18);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .mobile-bar {
        display: flex; align-items: center; justify-content: space-between;
        background: #fff; border-bottom: 1px solid var(--borda);
        padding: .55rem .9rem; position: sticky; top: 0; z-index: 10;
    }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
}

.container { max-width: 1040px; margin: 1.5rem auto; padding: 0 1.25rem; }

h1 { font-size: 1.45rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; }

.card {
    background: #fff;
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    border: none;
    border-radius: 6px;
    padding: .55rem 1rem;
    font-size: .92rem;
    cursor: pointer;
    text-decoration: none;
    background: var(--azul-claro);
    color: #fff;
}
.btn:hover { background: var(--azul); }
.btn-ghost { background: #fff; border: 1px solid var(--borda); color: var(--texto); }
.btn-ghost:hover { background: var(--cinza); }

label { display: block; font-size: .85rem; margin: .75rem 0 .25rem; font-weight: 600; }
input, select, textarea {
    width: 100%;
    padding: .55rem .65rem;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font-size: .95rem;
    font-family: inherit;
}

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--borda); font-size: .92rem; }
th { background: #fafbfc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #5a6672; }

.flash { background: #e8f4ec; border: 1px solid #bcdfca; color: var(--ok); padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.error { color: var(--erro); font-size: .88rem; margin-top: .4rem; }

.linkbtn { background: none; border: none; color: var(--azul-claro); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.linkbtn:hover { color: var(--azul); }

.footer { text-align: center; color: #8a94a0; padding: 2rem 0; }

/* Tela de login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--azul); }
.login-card { background: #fff; border-radius: 10px; padding: 2rem; width: 340px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { text-align: center; }
.login-card .logo-big { text-align: center; font-size: 2rem; color: var(--dourado); }

/* Dashboard cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi { background: #fff; border: 1px solid var(--borda); border-radius: 8px; padding: 1rem 1.25rem; }
.kpi .label { font-size: .8rem; color: #6b7682; text-transform: uppercase; }
.kpi .value { font-size: 1.5rem; font-weight: 700; color: var(--azul); }

/* Gráfico de barras (dashboard) */
.chart { display: flex; align-items: flex-end; gap: 1rem; height: 170px; padding: .5rem 0; overflow-x: auto; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 44px; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bar { width: 16px; border-radius: 3px 3px 0 0; background: var(--borda); min-height: 2px; }
.bar-in { background: var(--azul-claro); }
.bar-out { background: var(--dourado); }
.chart-label { font-size: .75rem; color: #6b7682; }
.chart-legend { display: flex; gap: 1.25rem; font-size: .85rem; color: #5a6672; margin-top: .5rem; }
.chart-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.sw-in { background: var(--azul-claro); }
.sw-out { background: var(--dourado); }

/* Impressão de relatório */
@media print {
    .sidebar, .mobile-bar, .footer, .nav-backdrop, .no-print { display: none !important; }
    .app-shell { display: block; }
    .container { margin: 0; max-width: none; }
    .card { border: none; padding: 0; }
}
