/* ============================
   ERP Web - Estilo Principal
   ============================ */

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

:root {
    --azul:       #1a3f6f;
    --azul-md:    #2563a8;
    --azul-lt:    #dbeafe;
    --azul-acc:   #3b82f6;
    --verde:      #16a34a;
    --verde-lt:   #dcfce7;
    --vermelho:   #dc2626;
    --verm-lt:    #fee2e2;
    --amarelo:    #d97706;
    --amar-lt:    #fef3c7;
    --cinza-1:    #f8fafc;
    --cinza-2:    #f1f5f9;
    --cinza-3:    #e2e8f0;
    --cinza-4:    #cbd5e1;
    --cinza-5:    #94a3b8;
    --cinza-6:    #64748b;
    --cinza-7:    #334155;
    --cinza-8:    #1e293b;
    --branco:     #ffffff;
    --sombra-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --sombra-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --sombra-lg:  0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);
    --radius:     8px;
    --radius-lg:  12px;
    --fonte:      'Sora', sans-serif;
    --fonte-mono: 'JetBrains Mono', monospace;
}

body {
    font-family: var(--fonte);
    background: var(--cinza-2);
    color: var(--cinza-8);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ---- NAVBAR ---- */
.navbar {
    background: var(--azul);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--sombra-md);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px; height: 34px;
    background: var(--azul-acc);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 600; color: #fff;
}

.brand-name {
    font-size: 16px; font-weight: 600;
    color: #fff; letter-spacing: .5px;
}
.brand-accent { color: #93c5fd; }

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-group { position: relative; }

.nav-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-family: var(--fonte);
    font-size: 13.5px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.nav-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--branco);
    border-radius: var(--radius-lg);
    box-shadow: var(--sombra-lg);
    min-width: 200px;
    overflow: hidden;
    border: 1px solid var(--cinza-3);
    z-index: 999;
}
.dropdown.open { display: block; }
.dropdown a {
    display: block;
    padding: 9px 16px;
    color: var(--cinza-7);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .1s;
}
.dropdown a:hover { background: var(--cinza-1); color: var(--azul-md); }

.navbar-user {
    display: flex; align-items: center; gap: 10px;
    margin-left: auto;
}
.user-name { font-size: 13px; color: #93c5fd; }
.btn-sair {
    font-size: 12.5px; padding: 4px 12px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px; color: #cbd5e1;
    text-decoration: none;
    transition: all .15s;
}
.btn-sair:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---- MAIN ---- */
.main-content { padding: 1.5rem 2rem; max-width: 1400px; margin: 0 auto; }

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-title {
    font-size: 20px; font-weight: 600;
    color: var(--cinza-8);
}
.page-title small {
    display: block; font-size: 12px;
    font-weight: 400; color: var(--cinza-5);
    margin-top: 2px;
}

/* ---- CARDS ---- */
.card {
    background: var(--branco);
    border-radius: var(--radius-lg);
    box-shadow: var(--sombra-sm);
    border: 1px solid var(--cinza-3);
}
.card-header {
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--cinza-3);
    font-weight: 600;
    font-size: 14px;
    color: var(--cinza-7);
    display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 1.25rem; }

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--branco);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--cinza-3);
    box-shadow: var(--sombra-sm);
}
.stat-label { font-size: 12px; color: var(--cinza-5); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 22px; font-weight: 600; color: var(--cinza-8); margin-top: 4px; font-family: var(--fonte-mono); }
.stat-card.verde .stat-value { color: var(--verde); }
.stat-card.azul  .stat-value { color: var(--azul-md); }
.stat-card.amar  .stat-value { color: var(--amarelo); }
.stat-card.verm  .stat-value { color: var(--vermelho); }

/* ---- TABELAS ---- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    background: var(--cinza-1);
    padding: 9px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--cinza-5);
    border-bottom: 1px solid var(--cinza-3);
    white-space: nowrap;
}
tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--cinza-2);
    color: var(--cinza-7);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--cinza-1); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--fonte-mono); }

/* ---- FORMULÁRIOS ---- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group.col2 { grid-column: span 2; }

label { font-size: 12px; font-weight: 600; color: var(--cinza-6); text-transform: uppercase; letter-spacing: .4px; }
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid var(--cinza-3);
    border-radius: var(--radius);
    font-family: var(--fonte);
    font-size: 13.5px;
    color: var(--cinza-8);
    background: var(--branco);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--azul-acc);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea { resize: vertical; min-height: 70px; }

/* ---- BOTÕES ---- */
.btn {
    display: inline-flex;
    align-items: center; gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius);
    font-family: var(--fonte);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary   { background: var(--azul-md);  color: #fff; }
.btn-primary:hover   { background: var(--azul);     filter: brightness(1.05); }
.btn-success   { background: var(--verde);    color: #fff; }
.btn-success:hover   { filter: brightness(1.05); }
.btn-danger    { background: var(--vermelho); color: #fff; }
.btn-danger:hover    { filter: brightness(1.05); }
.btn-warning   { background: var(--amarelo);  color: #fff; }
.btn-warning:hover   { filter: brightness(1.05); }
.btn-secondary { background: var(--cinza-3);  color: var(--cinza-7); }
.btn-secondary:hover { background: var(--cinza-4); }
.btn-outline   { background: transparent; border: 1.5px solid var(--cinza-3); color: var(--cinza-7); }
.btn-outline:hover   { border-color: var(--azul-acc); color: var(--azul-md); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }

/* ---- BADGES ---- */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 20px;
    font-size: 11.5px; font-weight: 600;
}
.badge-verde  { background: var(--verde-lt);   color: #15803d; }
.badge-verm   { background: var(--verm-lt);    color: #b91c1c; }
.badge-amar   { background: var(--amar-lt);    color: #92400e; }
.badge-azul   { background: var(--azul-lt);    color: #1d4ed8; }
.badge-cinza  { background: var(--cinza-2);    color: var(--cinza-6); }

/* ---- FILTROS / BUSCA ---- */
.filtros {
    display: flex; align-items: center; gap: .75rem;
    margin-bottom: 1rem; flex-wrap: wrap;
}
.filtros input[type="text"],
.filtros input[type="date"],
.filtros select { width: auto; min-width: 160px; }
.search-box { position: relative; }
.search-box input { padding-left: 32px; }
.search-box::before {
    content: "🔍";
    position: absolute; left: 9px; top: 50%;
    transform: translateY(-50%); font-size: 13px;
    pointer-events: none;
}

/* ---- MODAIS ---- */
.modal-overlay {
    display: none; position: fixed;
    inset: 0; background: rgba(0,0,0,.45);
    z-index: 2000;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--branco);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    width: 90%; max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--cinza-3);
    display: flex; align-items: center;
    justify-content: space-between;
    font-weight: 600; font-size: 15px;
}
.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--cinza-5); line-height: 1;
}
.modal-close:hover { color: var(--vermelho); }
.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: .875rem 1.25rem;
    border-top: 1px solid var(--cinza-3);
    display: flex; justify-content: flex-end; gap: .5rem;
}

/* ---- ALERTAS ---- */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 13.5px;
    border-left: 4px solid;
}
.alert-success { background: var(--verde-lt);  border-color: var(--verde);    color: #166534; }
.alert-danger   { background: var(--verm-lt);  border-color: var(--vermelho); color: #991b1b; }
.alert-warning  { background: var(--amar-lt);  border-color: var(--amarelo);  color: #92400e; }
.alert-info     { background: var(--azul-lt);  border-color: var(--azul-acc); color: #1e40af; }

/* ---- PAGINAÇÃO ---- */
.paginacao {
    display: flex; align-items: center; gap: 4px;
    justify-content: center; margin-top: 1rem;
}
.paginacao a, .paginacao span {
    padding: 5px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    text-decoration: none;
    color: var(--cinza-7);
    border: 1px solid var(--cinza-3);
    transition: all .1s;
}
.paginacao a:hover  { background: var(--azul-lt); border-color: var(--azul-acc); color: var(--azul-md); }
.paginacao .ativo   { background: var(--azul-md); color: #fff; border-color: var(--azul-md); }

/* ---- FOOTER ---- */
.footer {
    text-align: center; padding: 1rem;
    font-size: 12px; color: var(--cinza-5);
    border-top: 1px solid var(--cinza-3);
    margin-top: 2rem;
}

/* ---- DASHBOARD ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }
    .navbar-menu { display: none; }
}

/* ---- FRENTE DE CAIXA ---- */
.pdv-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1rem;
    height: calc(100vh - 120px);
}
.pdv-produtos { overflow-y: auto; }
.pdv-totais {
    background: var(--cinza-8);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    color: #fff;
    display: flex; flex-direction: column; gap: .75rem;
}
.pdv-total-linha {
    display: flex; justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 14px; color: #94a3b8;
}
.pdv-total-linha.destaque { border-bottom: none; }
.pdv-total-linha.destaque .label { font-size: 20px; font-weight: 600; color: #fff; }
.pdv-total-linha.destaque .valor { font-size: 26px; font-weight: 700; color: #4ade80; font-family: var(--fonte-mono); }
.pdv-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: auto; }
.pdv-btns .btn { justify-content: center; font-size: 12.5px; }
.pdv-btn-concluir {
    grid-column: 1 / -1;
    background: var(--verde);
    color: #fff; font-size: 15px; font-weight: 600;
    padding: 12px;
}

/* MISC */
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-none { display: none !important; }
.text-muted { color: var(--cinza-5); }
.text-success { color: var(--verde); }
.text-danger  { color: var(--vermelho); }
hr { border: none; border-top: 1px solid var(--cinza-3); margin: 1rem 0; }

/* LOGIN */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--azul) 0%, #0f2952 100%);
}
.login-card {
    background: var(--branco);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
    box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-logo {
    display: flex; flex-direction: column;
    align-items: center; gap: .5rem;
    margin-bottom: 2rem;
}
.login-logo .icon {
    width: 60px; height: 60px;
    background: var(--azul-md);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700; color: #fff;
}
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--cinza-8); }
.login-logo p  { font-size: 13px; color: var(--cinza-5); }

/* ---- MENUS DROPDOWN APRIMORADOS ---- */
.nav-arrow { font-size: 9px; opacity: .7; margin-left: 2px; }
.dd-section {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .7px; color: var(--cinza-5);
    padding: 8px 14px 4px; margin-top: 2px;
    border-top: 0.5px solid var(--cinza-3);
}
.dd-section:first-child { border-top: none; margin-top: 0; }
.dd-ico { font-size: 14px; width: 20px; display: inline-block; }
.dropdown a {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    color: var(--cinza-7);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .1s;
    border-radius: 0;
}
.dropdown a:hover { background: var(--cinza-1); color: var(--azul-md); }

/* Acesso negado */
.acesso-negado {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 60vh; text-align: center;
    gap: 1rem;
}
.acesso-negado .ico-grande { font-size: 60px; }
.acesso-negado h2 { font-size: 22px; color: var(--cinza-7); }
.acesso-negado p  { color: var(--cinza-5); font-size: 14px; }

/* Badge perfil */
.badge-admin { background: #ede9fe; color: #6d28d9; border: 0.5px solid #c4b5fd; }
.badge-operador { background: var(--cinza-2); color: var(--cinza-6); border: 0.5px solid var(--cinza-3); }
.badge-financeiro { background: #dbeafe; color: #1d4ed8; border: 0.5px solid #93c5fd; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.toggle { position: relative; width: 42px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--cinza-3); border-radius: 22px; cursor: pointer;
    transition: background .2s;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; left: 3px; top: 3px;
    transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--verde); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================================
   RESPONSIVIDADE — telas menores (tablets e celulares)
   ============================================================ */

/* Tabelas: scroll horizontal em telas pequenas */
.table-wrapper, .card-body { overflow-x: auto; }
table { min-width: 500px; }

/* Stats grid: 2 colunas em tablet, 1 em mobile */
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .main-content { padding: .75rem; }

    /* Cabeçalho de página */
    .page-header { flex-wrap: wrap; gap: .5rem; }
    .page-header .btn { font-size: 12px; padding: 6px 12px; }

    /* Filtros em coluna */
    .filtros { flex-direction: column; align-items: stretch; }
    .filtros form { flex-wrap: wrap; }

    /* Cards de formulário em coluna */
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:1fr 380px"],
    [style*="grid-template-columns: 1fr 380px"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:2fr 1fr"],
    [style*="grid-template-columns: 2fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3,1fr)"] { grid-template-columns: 1fr 1fr !important; }
    [style*="grid-template-columns:repeat(4,1fr)"],
    [style*="grid-template-columns: repeat(4,1fr)"] { grid-template-columns: 1fr 1fr !important; }

    /* Navbar: esconder textos de menu em mobile */
    .navbar-brand span { display: none; }

    /* Modais responsivos */
    .modal-box { max-width: 100% !important; margin: .5rem; border-radius: 10px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr !important; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header h1 { font-size: 18px; }
    table { min-width: 380px; font-size: 12px; }
    .btn { font-size: 12px; }
    .stat-value { font-size: 20px; }
}

/* PDV responsivo */
@media (max-width: 900px) {
    .pdv-wrap {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr auto;
        height: auto !important;
        min-height: 100vh;
    }
    .pdv-dir {
        max-height: none !important;
        border-left: none !important;
        border-top: 1px solid #1e293b;
    }
}

/* Modal de formas de pagamento responsivo */
@media (max-width: 540px) {
    #mp-formas { grid-template-columns: 1fr 1fr !important; }
    .pdv-modal { padding: 1.25rem !important; }
}


.badge-info{background:rgba(59,130,246,.15);color:#93c5fd;border:1px solid rgba(59,130,246,.25)}
.card-footer-actions{display:flex;gap:.6rem;align-items:center;padding:0 1rem 1rem}
.kpi-list.compact .list-item{padding:.65rem 0}
