:root {
    --bg: #f4f7fb;
    --panel: #fff;
    --text: #172033;
    --muted: #6f7a8c;
    --line: #e5eaf1;
    --primary: #3267f4;
    --primary2: #194ee2;
    --shadow: 0 12px 40px rgba(28,45,90,.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* =========================================================
   ESTRUTURA PRINCIPAL
   ========================================================= */

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

.sidebar {
    width: 245px;
    background: linear-gradient(180deg, #eef4ff, #e2ebfa);
    color: #172033;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
}

/* =========================================================
   MARCA / LOGO
   ========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 8px 24px;
}

/*
    Antes essas classes criavam o quadrado azul com a letra E.

    Agora o fundo foi removido porque elas recebem uma imagem.
*/
.brand-mark,
.logo-big {
    display: grid;
    place-items: center;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
}

/*
    Logo utilizada no menu lateral.
*/
.brand-mark {
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid #cbd8ec;
    border-radius: 16px;
    padding: 8px;
}

/*
    Logo utilizada na tela de login.
*/
.logo-big {
    width: 150px;
    height: 150px;
    margin: 0 auto 34px auto;
}

    /*
    Mantém a logo proporcional.

    A imagem nunca será esticada ou deformada.
*/
    .brand-mark img,
    .logo-big img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        display: block;
    }

/* =========================================================
   IDENTIDADE NO MENU
   ========================================================= */

.brand strong {
    display: block;
    font-size: 18px;
    color: #172033;
}

.brand small,
.sidebar-user small {
    display: block;
    color: #66758c;
    font-size: 11px;
    margin-top: 2px;
}

/* =========================================================
   MENU LATERAL
   ========================================================= */

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

    .sidebar nav a {
        color: #34445f;
        padding: 12px 13px;
        border-radius: 12px;
        display: flex;
        gap: 12px;
        align-items: center;
    }

        .sidebar nav a:hover {
            background: #d3e0f5;
            color: #172033;
        }

/* =========================================================
   USUÁRIO
   ========================================================= */

.sidebar-user {
    margin-top: auto;
    border-top: 1px solid #cbd8ec;
    padding: 18px 8px 0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #d3e0f5;
    color: #172033;
    display: grid;
    place-items: center;
    font-weight: 700;
}

/* =========================================================
   CONTEÚDO
   ========================================================= */

.main-content {
    margin-left: 245px;
    width: calc(100% - 245px);
    min-width: 0;
}

.topbar {
    height: 68px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.spacer {
    flex: 1;
}

.menu-btn {
    display: none;
    border: 0;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
}

.content-wrap {
    padding: 30px;
    max-width: 1500px;
    margin: auto;
}

/* =========================================================
   CABEÇALHO DAS PÁGINAS
   ========================================================= */

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

    .page-head h1 {
        font-size: 28px;
        margin: 0 0 5px;
    }

    .page-head p,
    .muted,
    .card-head p {
        color: var(--muted);
        margin: 0;
    }

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

.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: #26334a;
    padding: 10px 15px;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 650;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

    .btn:hover {
        border-color: #cdd6e5;
    }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--primary2);
    }

.btn-ghost {
    background: transparent;
}

.btn-wide {
    width: 100%;
    padding: 13px;
}

/* =========================================================
   INDICADORES
   ========================================================= */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 16px;
    margin-bottom: 20px;
}

    .kpi-grid.three {
        grid-template-columns: repeat(3,minmax(0,1fr));
    }

.kpi {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 22px;
}

    .kpi span {
        display: block;
        color: var(--muted);
        font-size: 13px;
        margin-bottom: 8px;
    }

    .kpi strong {
        font-size: 30px;
    }

    .kpi .small-value {
        font-size: 18px;
    }

/* =========================================================
   CARTÕES
   ========================================================= */

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-head {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .card-head h3 {
        margin: 0 0 4px;
        font-size: 17px;
    }

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

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    font-size: 13px;
}

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #778297;
    background: #fafbfd;
}

tbody tr:hover {
    background: #fbfcff;
}

.empty {
    text-align: center !important;
    color: var(--muted);
    padding: 32px !important;
}

/* =========================================================
   BADGES
   ========================================================= */

.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    margin: 2px;
}

    .badge.green {
        background: #e9f8ef;
        color: #177448;
    }

    .badge.red {
        background: #ffeded;
        color: #b32929;
    }

    .badge.blue {
        background: #eaf0ff;
        color: #315dc5;
    }

    .badge.amber {
        background: #fff4d8;
        color: #8a6410;
    }

    .badge.gray {
        background: #edf0f4;
        color: #606a79;
    }

/* =========================================================
   AÇÕES
   ========================================================= */

.actions {
    white-space: nowrap;
}

    .actions a {
        margin-right: 11px;
        font-weight: 650;
    }

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

.filters {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

    .filters input,
    .filters select {
        min-width: 160px;
    }

    .filters > input:first-child {
        flex: 1;
        min-width: 240px;
    }

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

.form-card {
    padding: 24px;
}

    .form-card.narrow {
        max-width: 760px;
    }

.form-grid {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 18px;
}

    .form-grid.two {
        grid-template-columns: repeat(2,minmax(0,1fr));
        margin: 16px 0;
    }

.span2 {
    grid-column: span 2;
}

.span3 {
    grid-column: span 3;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #4d596d;
    margin: 0 0 7px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #dce3ed;
    background: #fff;
    border-radius: 11px;
    padding: 11px 12px;
    color: var(--text);
    outline: none;
}

    input:focus,
    select:focus,
    textarea:focus {
        border-color: #7e9df6;
        box-shadow: 0 0 0 3px rgba(50,103,244,.1);
    }

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

/* =========================================================
   CHECKBOX
   ========================================================= */

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
}

    .check input {
        width: auto;
    }

    .check span {
        font-weight: 500;
    }

.check-wrap {
    padding-top: 23px;
}

    .check-wrap small,
    small {
        color: var(--muted);
    }

/* =========================================================
   VALIDAÇÕES
   ========================================================= */

.validation {
    background: #fff0f0;
    color: #a62929;
    border: 1px solid #ffd3d3;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

    .validation:empty {
        display: none;
    }

.field-validation-error {
    font-size: 11px;
    color: #b22929;
}

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

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
}

    .alert.success {
        background: #eaf8ef;
        color: #176c43;
        border: 1px solid #caecd7;
    }

/* =========================================================
   SERIAIS
   ========================================================= */

.serial-grid {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .serial-grid span {
        padding: 8px 10px;
        border-radius: 10px;
        background: #f3f6fb;
        border: 1px solid var(--line);
        font-family: Consolas, monospace;
        font-size: 12px;
    }

/* =========================================================
   LOGIN
   ========================================================= */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 10% 20%,#e5ecff,transparent 34%), radial-gradient(circle at 90% 80%,#e8f7ff,transparent 30%), #f6f8fc;
}

.login-card {
    width: min(930px,100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 28px 80px rgba(30,48,90,.14);
    border-radius: 26px;
    overflow: hidden;
}

.login-side {
    padding: 56px;
    background: linear-gradient(145deg, #dfe9ff, #cddcff);
    color: #172033;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

    .login-side h1 {
        font-size: 34px;
        margin: 0 0 14px;
    }

    .login-side p {
        color: #aab8ce;
        line-height: 1.65;
        max-width: 420px;
    }

.login-form {
    padding: 52px;
}

    .login-form h2 {
        font-size: 28px;
        margin: 0 0 6px;
    }

    .login-form label:not(.check) {
        margin-top: 18px;
    }

.login-hint {
    margin-top: 22px;
    padding: 12px 14px;
    background: #f5f7fb;
    border-radius: 12px;
    color: #5f6978;
    font-size: 12px;
    line-height: 1.7;
}

    .login-hint code {
        background: #e8edf6;
        padding: 2px 5px;
        border-radius: 5px;
    }

/* =========================================================
   MENU MOBILE
   ========================================================= */

.menu-open .sidebar {
    transform: translateX(0);
}

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

@media(max-width:1000px) {

    .kpi-grid {
        grid-template-columns: repeat(2,1fr);
    }

    .form-grid {
        grid-template-columns: repeat(2,1fr);
    }

    .span3 {
        grid-column: span 2;
    }

    .span2 {
        grid-column: span 2;
    }
}

@media(max-width:760px) {

    .sidebar {
        transform: translateX(-100%);
        transition: .2s;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-btn {
        display: block;
    }

    .content-wrap {
        padding: 20px 14px;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .kpi-grid,
    .kpi-grid.three {
        grid-template-columns: 1fr 1fr;
    }

    .login-card {
        grid-template-columns: 1fr;
    }

    .login-side {
        display: none;
    }

    .login-form {
        padding: 34px 26px;
    }

    .form-grid,
    .form-grid.two {
        grid-template-columns: 1fr;
    }

    .span2,
    .span3 {
        grid-column: span 1;
    }

    .filters {
        align-items: stretch;
        flex-direction: column;
    }

        .filters input,
        .filters select {
            width: 100%;
        }

    .card {
        border-radius: 14px;
    }
}

@media(max-width:460px) {

    .kpi-grid,
    .kpi-grid.three {
        grid-template-columns: 1fr;
    }

    .page-head h1 {
        font-size: 24px;
    }
}
