* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --azul: #0b6842;
    --azul-escuro: #06472e;
    --menu: #00472a;
    --texto: #20352a;
    --texto-suave: #66776c;
    --borda: #dfe8df;
    --fundo: #f2f6f1;
    --branco: #ffffff;
    --verde: #17633f;
    --amarelo: #f6c400;
    --laranja: #f15a00;
    --vermelho: #dc2626;
    --sombra: 0 10px 30px rgba(0, 55, 32, 0.08);
}

body {
    min-height: 100vh;
    color: var(--texto);
    background: var(--fundo);
    font-family: Arial, Helvetica, sans-serif;
}

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

button,
.btn {
    border: 0;
    cursor: pointer;
}

[hidden] {
    display: none;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px;
    background:
        radial-gradient(ellipse at 12% 90%, rgba(241, 90, 0, 0.12), transparent 35%),
        linear-gradient(135deg, #e8efe8 0%, #fff9e4 100%);
}

.login-shell {
    width: min(1120px, 100%);
    min-height: min(680px, calc(100dvh - 64px));
    display: grid;
    grid-template-columns: 0.95fr 1.05fr;
    overflow: hidden;
    background: var(--branco);
    border: 1px solid rgba(0, 71, 42, 0.1);
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0, 55, 32, 0.15);
}

.login-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: clamp(32px, 5vw, 64px);
    color: var(--branco);
    background: var(--menu);
}

.brand-logo {
    display: block;
    width: min(380px, 100%);
    height: auto;
    margin: auto 0;
    border-radius: 3px;
}

.login-brand-copy span,
.login-form-heading span {
    display: block;
    margin-bottom: 12px;
    color: var(--amarelo);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.login-brand h1 {
    color: var(--branco);
    font-size: 2rem;
    line-height: 1.1;
}

.login,
.form-panel,
.tabela-container,
.resumo,
.danger-zone,
.filters,
.card {
    background: var(--branco);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 10px;
    box-shadow: var(--sombra);
}

.login {
    display: grid;
    align-content: center;
    gap: 22px;
    padding: clamp(36px, 7vw, 88px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.login-form-heading h2 {
    color: var(--menu);
    font-size: 1.8rem;
}

.login-form-heading p {
    margin-top: 8px;
    color: var(--texto-suave);
    line-height: 1.5;
}

.login-form-heading span {
    color: var(--laranja);
}

.login label {
    gap: 9px;
}

.login input {
    min-height: 50px;
    background: #f7faf6;
}

.login button {
    min-height: 50px;
    margin-top: 2px;
    background: var(--menu);
}

.login button:hover {
    background: var(--azul);
}

.login .form-help {
    margin-top: -6px;
    text-align: center;
}

.settings-subtitle {
    grid-column: 1 / -1;
    padding-top: 8px;
    color: var(--menu);
    border-top: 1px solid var(--borda);
}

.role-operador [data-admin-only] {
    display: none !important;
}

.role-operador .dashboard-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login h2,
.form-panel h2,
.danger-zone h2 {
    font-size: 1.25rem;
}

label {
    display: grid;
    gap: 8px;
    color: var(--texto);
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    color: var(--texto);
    background: #f9fafb;
    border: 1px solid var(--borda);
    border-radius: 8px;
    outline: 0;
}

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

input:focus,
select:focus,
textarea:focus {
    background: var(--branco);
    border-color: var(--azul);
    box-shadow: 0 0 0 4px rgba(11, 104, 66, 0.13);
}

.form-help {
    color: var(--texto-suave);
    font-size: 0.86rem;
    line-height: 1.45;
}

.stock-warning {
    color: var(--vermelho);
    font-weight: 700;
}

.stock-entry-link {
    display: inline-block;
    color: var(--azul);
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.stock-entry-link[hidden] {
    display: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    padding: 22px 14px;
    overflow-y: auto;
    color: var(--branco);
    background: var(--menu);
}

.mobile-menu-toggle,
.mobile-menu-backdrop {
    display: none;
}

.logo {
    display: block;
    margin: 0 8px 26px;
    overflow: hidden;
    border-radius: 3px;
}

.logo img {
    display: block;
    width: 100%;
    height: auto;
}

.menu {
    display: grid;
    gap: 7px;
}

.menu a {
    display: block;
    padding: 12px 14px;
    color: #e1ece2;
    border-left: 3px solid transparent;
    border-radius: 3px;
    font-weight: 700;
    transition: 0.2s ease;
}

.menu a:hover,
.menu a.active {
    color: #fff9df;
    background: rgba(246, 196, 0, 0.13);
    border-left-color: var(--amarelo);
}

.menu [data-logout] {
    width: 100%;
    min-height: 0;
    padding: 12px 14px;
    color: #e1ece2;
    background: transparent;
    border-left: 3px solid transparent;
    border-radius: 3px;
    font-size: 1rem;
    font-weight: 700;
    justify-content: flex-start;
    transition: 0.2s ease;
}

.menu [data-logout]:hover {
    color: #fff9df;
    background: rgba(246, 196, 0, 0.13);
    border-left-color: var(--amarelo);
    transform: none;
}

.main {
    min-height: 100vh;
    margin-left: 240px;
    padding: 26px 34px 40px;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 20px;
    margin-bottom: 26px;
}

.topbar h1 {
    margin-bottom: 5px;
    font-size: 1.8rem;
}

.topbar p,
.section-title span,
.danger-zone p {
    color: var(--texto-suave);
}

.usuario {
    padding: 10px 14px;
    background: var(--branco);
    border: 1px solid var(--borda);
    border-radius: 8px;
    font-weight: 700;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.cards-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
    padding: 21px;
    border-top: 3px solid var(--amarelo);
}

.cards .card:nth-child(4n) {
    border-top-color: var(--laranja);
}

.card h3 {
    margin-bottom: 10px;
    color: var(--texto-suave);
    font-size: 0.9rem;
}

.numero {
    font-size: clamp(1.55rem, 3vw, 1.9rem);
    font-weight: 800;
}

.financial-positive {
    color: var(--verde);
}

.financial-negative {
    color: var(--vermelho);
}

.descricao {
    margin-top: 8px;
    color: var(--texto-suave);
    font-size: 0.85rem;
}

.acoes,
.filters {
    display: flex;
    align-items: end;
    gap: 14px;
    margin-bottom: 24px;
}

.filters label {
    flex: 1;
}

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 18px;
    color: var(--branco);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 800;
    transition: 0.2s ease;
}

.btn:hover,
button:hover {
    transform: translateY(-1px);
}

.btn-primary,
button {
    background: var(--azul);
}

.btn-primary:hover,
button:hover {
    background: var(--azul-escuro);
}

.btn-secondary {
    color: #20352a;
    background: var(--amarelo);
}

.btn-secondary:hover {
    background: #e7b800;
}

.btn-danger {
    background: var(--vermelho);
}

.btn-small {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 0.82rem;
}

.btn-muted {
    color: var(--texto);
    background: #e4ebe3;
}

[data-employee-adjustment][hidden],
[data-open-employee-doc][hidden] {
    display: none;
}

.resumo,
.form-panel,
.tabela-container,
.danger-zone,
.filters {
    padding: 24px;
    margin-bottom: 24px;
}

.resumo h2,
.tabela-container h2 {
    font-size: 1.25rem;
}

.resumo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 18px;
}

.closure-preview {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

output {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 11px 12px;
    color: var(--texto-suave);
    background: #f7faf6;
    border: 1px solid var(--borda);
    border-radius: 8px;
}

.resumo-item {
    min-width: 0;
    padding: 18px;
    background: #f7faf6;
    border: 1px solid var(--borda);
    border-radius: 8px;
}

.resumo-item span {
    display: block;
    margin-bottom: 7px;
    color: var(--texto-suave);
    font-size: 0.9rem;
}

.resumo-item strong {
    overflow-wrap: anywhere;
    font-size: 1.6rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
    align-items: end;
}

.form-grid:has([data-route-filter]) {
    grid-template-columns: minmax(180px, 1.2fr) minmax(260px, 1.8fr) minmax(130px, 0.8fr) minmax(120px, 0.7fr) minmax(180px, auto);
}

.dashboard-entry-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 16px;
    align-items: end;
}

.dashboard-entry-form .btn {
    min-width: 190px;
}

.form-grid button {
    width: 100%;
}

.pix-type,
.pix-key {
    display: block;
}

.pix-type {
    margin-bottom: 3px;
    color: var(--texto-suave);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.pix-key {
    overflow-wrap: anywhere;
}

.table-actions {
    white-space: nowrap;
}

.table-actions .btn + .btn {
    margin-left: 5px;
}

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

.tabela-container {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

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

th,
td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--borda);
    vertical-align: middle;
}

th {
    color: var(--texto-suave);
    font-size: 0.82rem;
}

td {
    font-size: 0.92rem;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.status-aberto {
    color: #725700;
    background: #fff2bd;
}

.status-fechado,
.status-pago,
.status-ativo {
    color: #145538;
    background: #dcefe2;
}

.status-inativo,
.status-pendente {
    color: #991b1b;
    background: #fee2e2;
}

.empty-row {
    color: var(--texto-suave);
    text-align: center;
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10;
    max-width: 360px;
    padding: 14px 16px;
    color: var(--branco);
    background: var(--menu);
    border-radius: 8px;
    box-shadow: var(--sombra);
    font-weight: 700;
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 0.85fr 1.15fr;
    }

    .login-brand {
        padding: 36px;
    }

    .login {
        padding: 44px;
    }
}

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

    .form-grid:has([data-route-filter]) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .login-page {
        padding: 16px;
    }

    .login-shell {
        grid-template-columns: 1fr;
        min-height: 0;
        width: min(520px, 100%);
    }

    .login-brand {
        min-height: 220px;
        padding: 24px 28px;
    }

    .brand-logo {
        width: min(240px, 78%);
        margin: 0 0 16px;
    }

    .login-brand-copy span {
        margin-bottom: 6px;
    }

    .login-brand h1 {
        font-size: 1.55rem;
    }

    .login {
        gap: 18px;
        padding: 30px 28px 28px;
    }

    .login-form-heading h2 {
        font-size: 1.55rem;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 8;
        display: block;
        width: min(280px, 85vw);
        height: 100vh;
        height: 100dvh;
        padding: 22px 14px;
        overflow-y: auto;
        box-shadow: 8px 0 24px rgba(0, 55, 32, 0.2);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }

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

    .logo {
        margin: 54px 8px 26px;
        max-width: 210px;
    }

    .menu {
        display: grid;
        gap: 7px;
    }

    .menu a {
        padding: 12px 14px;
        font-size: 0.92rem;
    }

    .mobile-menu-toggle {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 10;
        display: inline-flex;
        width: auto;
        min-height: 44px;
        padding: 10px 14px;
        color: var(--branco);
        background: var(--menu);
        box-shadow: var(--sombra);
    }

    body.menu-open .mobile-menu-toggle {
        right: calc(100% - min(280px, 85vw) + 12px);
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 7;
        display: none;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 0;
        background: rgba(0, 45, 27, 0.46);
        border-radius: 0;
    }

    body.menu-open .mobile-menu-backdrop {
        display: block;
    }

    body.menu-open {
        overflow: hidden;
    }

    .mobile-menu-toggle:focus-visible,
    .menu a:focus-visible {
        outline: 3px solid var(--amarelo);
        outline-offset: 2px;
    }

    .main {
        min-width: 0;
        margin-left: 0;
        padding: 88px 16px 24px;
    }

    .topbar,
    .section-title,
    .danger-zone,
    .acoes,
    .filters {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .form-grid:has([data-route-filter]) {
        grid-template-columns: minmax(0, 1fr);
    }

    .closure-preview {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .closure-preview .resumo-item {
        padding: 12px;
    }

    .closure-preview .resumo-item strong {
        font-size: 1.25rem;
    }

    .role-operador .dashboard-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-entry-form {
        grid-template-columns: 1fr;
    }

    .resumo,
    .form-panel,
    .tabela-container,
    .danger-zone,
    .filters {
        padding: 16px;
    }

    .btn,
    button {
        width: 100%;
    }

    .table-actions .btn {
        width: auto;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 76px 12px 20px;
    }

    .topbar h1 {
        font-size: 1.5rem;
    }

    .usuario {
        align-self: flex-start;
    }

    .resumo,
    .form-panel,
    .tabela-container,
    .danger-zone,
    .filters {
        padding: 12px;
    }

    .card {
        padding: 16px;
    }

    th,
    td {
        padding: 11px 9px;
    }
}

@media print {
    .sidebar,
    .mobile-menu-toggle,
    .mobile-menu-backdrop,
    .no-print,
    .toast {
        display: none !important;
    }

    body {
        background: var(--branco);
    }

    .main {
        margin-left: 0;
        padding: 0;
    }

    .card,
    .tabela-container,
    .form-panel,
    .resumo {
        box-shadow: none;
    }

    table {
        min-width: 0;
    }

    .cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
