:root {
    --bg-color: #e2e8f0;
    --card-bg: #ffffff;
    --card-border: #cbd5e1;
    --card-hover-border: #94a3b8;
    --text-main: #0f172a;
    --text-muted: #334155;
    --accent-primary: #1d4ed8;
    --accent-secondary: #0369a1;
    --accent-glow: rgba(29, 78, 216, 0.15);
}

body {
    background-color: var(--bg-color) !important;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.06) 0%, transparent 40%) !important;
    color: var(--text-main) !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Override cabecalho styling dynamically inserted by cabecalho.js */
#cabecalho {
    background: rgba(255, 255, 255, 0.5) !important;
    border-bottom: 1px solid var(--card-border) !important;
    padding: 5px 20px !important;
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-size: 12.5px !important;
    color: var(--text-muted) !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 12px !important;
}

#cabecalho b {
    color: var(--text-main) !important;
    font-weight: 600 !important;
}

#cabecalho a {
    color: var(--text-muted) !important;
    text-decoration: none !important;
    padding: 3px 10px !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid var(--card-border) !important;
    transition: all 0.2s ease !important;
}

#cabecalho a:hover {
    color: var(--accent-primary) !important;
    background: #ffffff !important;
    border-color: rgba(37, 99, 235, 0.25) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
}

.dashboard-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 18px 16px;
    box-sizing: border-box;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    box-sizing: border-box;
    margin: 12vh auto auto auto;
}

.header-title-section {
    margin-bottom: 18px;
    text-align: center;
}

.header-title-section h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px 0;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-title-section p {
    color: var(--text-muted);
    font-size: 14.5px;
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}

.dashboard-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.01);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0.8;
}

.dashboard-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.08), 0 10px 10px -5px rgba(37, 99, 235, 0.04);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 6px;
}

.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent-primary);
}

.card-icon svg {
    width: 14px !important;
    height: 14px !important;
}

.card-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

/* Cabeçalho do card de filtros um pouco mais compacto */
.dashboard-card:has(form) .card-header {
    gap: 6px;
    padding-bottom: 4px;
}

.dashboard-card:has(form) .card-icon {
    width: 22px;
    height: 22px;
}

.dashboard-card:has(form) .card-icon svg {
    width: 12px !important;
    height: 12px !important;
}

.dashboard-card:has(form) .card-title {
    font-size: 13px;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(37, 99, 235, 0.02);
    transition: all 0.2s ease;
}

.menu-link:hover {
    color: var(--text-main);
    background: #ffffff;
    border-color: rgba(37, 99, 235, 0.15);
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2) !important;
}

.menu-link-icon {
    font-size: 12px;
    color: var(--accent-primary);
    transition: transform 0.2s ease;
}

.menu-link:hover .menu-link-icon {
    transform: scale(1.2);
    color: var(--accent-secondary);
}

/* Botão Cancelar padrão dos formulários (new/edit) */
.btn-cancel {
    border: 1px solid var(--card-border) !important;
    padding: 0 20px !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    background: rgba(255, 255, 255, 0.4) !important;
    color: var(--text-main) !important;
    font-weight: 700 !important;
    width: 100% !important;
    text-align: center !important;
}

/* Section custom themes for index.html */
#secao-gerentes .dashboard-card::before {
    background: linear-gradient(90deg, #2563eb, #0891b2);
}
#secao-gerentes .card-icon {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}


#secao-administradores .dashboard-card::before {
    background: linear-gradient(90deg, #dc2626, #db2777);
}
#secao-administradores .card-icon {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

/* Native Forms (used in login.html) */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.form-label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.form-control {
    background: #ffffff;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    height: 32px;
    padding: 0 10px;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text-main);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-submit {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    height: 28px !important;
    padding: 0 16px !important;
    font-family: inherit;
    font-size: 13px !important;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0 !important;
    outline: none;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.error-message {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.4;
}

@media (max-width: 640px) {
    .dashboard-container {
        padding: 20px 15px;
    }
    .header-title-section h1 {
        font-size: 16px;
    }
    #cabecalho {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 10px;
        padding: 15px !important;
    }
    .card-header-actions {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    .action-btn-group {
        justify-content: flex-end;
    }
}

/* Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: #ffffff;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.modern-table th {
    background-color: #f1f5f9;
    color: var(--text-main);
    font-weight: 600;
    padding: 3px 8px;
    border-bottom: 1px solid var(--card-border);
}

.modern-table th:not(:last-child) {
    border-right: 1px solid var(--card-border);
}

.modern-table td {
    padding: 3px 8px;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-main);
}

.modern-table td:not(:last-child) {
    border-right: 1px solid #e2e8f0;
}

.modern-table tbody tr {
    transition: background-color 0.2s ease;
}

.modern-table tbody tr:hover {
    background-color: #f1f5f9;
}

.modern-table tbody tr:last-child td {
    border-bottom: none;
}

.no-data-msg {
    text-align: center;
    color: var(--text-muted);
    padding: 16px;
    font-size: 13.5px;
}

/* Form layout grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    align-items: flex-end;
}


.selected-row {
    background-color: rgba(37, 99, 235, 0.08) !important;
}

.clickable-row {
    cursor: pointer;
}

.action-btn-group {
    display: flex;
    gap: 8px;
}

/* Layout for filter forms in list.html and reports */
#filtro-form.form-grid,
#form-filtros.form-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 8px 16px !important;
    align-items: flex-end !important;
}

/* Compact Cancelar/Limpar buttons in all lists and reports */
#btn-limpar,
:is(#filtro-form, #form-filtros) .menu-link {
    height: 28px !important;
    padding: 0 16px !important;
    font-size: 12.5px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid var(--card-border) !important;
    background: rgba(255, 255, 255, 0.4) !important;
    color: var(--text-main) !important;
}

/* Ensure buttons in filter forms have auto width and no wrapping */
:is(#filtro-form, #form-filtros) button,
:is(#filtro-form, #form-filtros) a {
    width: auto !important;
    white-space: nowrap !important;
}

/* Stack labels above fields in filter panels */
:is(#filtro-form, #form-filtros) .form-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    margin-bottom: 0 !important;
}

:is(#filtro-form, #form-filtros) .form-label {
    width: auto !important;
    min-width: 0 !important;
    text-align: left !important;
    margin: 0 0 2px 0 !important;
}

:is(#filtro-form, #form-filtros) .form-control {
    width: 100% !important;
    max-width: 100% !important;
}

#filtro-form > div:not(.form-group),
#form-filtros.form-grid > div:not(.form-group) {
    grid-column: 1 / -1 !important;
    margin-left: 0 !important;
}

/* Compact layout for Movimento new/edit forms */
#movimento-form h3 {
    margin-top: 12px !important;
    margin-bottom: 6px !important;
    font-size: 13.5px !important;
}

#movimento-form .form-grid {
    margin-bottom: 12px !important;
    gap: 8px 12px !important;
}

#movimento-form .form-group {
    margin-bottom: 0 !important;
}

#movimento-form textarea.form-control {
    height: 72px !important;
    padding: 6px 10px !important;
}

#movimento-form .form-group:has(textarea) {
    margin-bottom: 10px !important;
}

#movimento-form #produtos-container {
    gap: 8px !important;
    margin-bottom: 12px !important;
}

#movimento-form h3 #btn-add-produto {
    height: 32px !important;
    font-size: 12px !important;
    padding: 0 12px !important;
}

#movimento-form > div[style*="display: flex"] {
    margin-top: 12px !important;
}

#movimento-form #btn-cancelar {
    height: 28px !important;
    padding: 0 16px !important;
    font-size: 12.5px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    margin-top: 0 !important;
}

#movimento-form #submit-btn {
    width: auto !important;
}


/* Shared layout utilities migrated from inline HTML styles */
.success-message {
    background-color: #d1fae5 !important;
    border-color: #a7f3d0 !important;
    color: #065f46 !important;
}

.results-panel { margin-top: 30px !important; }
.results-full-bleed {
    position: relative !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: max-content !important;
    max-width: calc(100vw - 48px) !important;
    box-sizing: border-box !important;
}

.periodo-titulo {
    text-align: left;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text-main);
    margin: 0 0 12px 0;
    padding-left: 10px;
}

.periodo-titulo:empty { display: none; }

.totais-gerais {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 16px;
    padding-left: 10px;
}

.totais-gerais:empty { display: none; }

.totais-gerais-item {
    display: grid;
    grid-template-columns: 180px 100px;
    text-align: left;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--text-main);
}

.totais-gerais-value {
    text-align: center;
}

.form-actions { display: flex !important; gap: 20px !important; }
.form-actions-sm { margin-top: 10px !important; }
.form-actions-md { margin-top: 20px !important; }
.flex-gap-10 { display: flex !important; gap: 10px !important; }
.flex-gap-10-end { display: flex !important; gap: 10px !important; align-items: flex-end !important; }
.two-column-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 16px !important; }
.two-column-grid-spaced { margin-top: 8px !important; }
.form-grid-tight { margin-bottom: 10px !important; }
.form-grid-count { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important; margin-bottom: 24px !important; }
.form-group-flush { margin-bottom: 0 !important; }
.container-sm { max-width: 550px !important; }
.container-md { max-width: 600px !important; }
.container-lg { max-width: 700px !important; }
.container-xl { max-width: 800px !important; }
.container-top-sm { margin-top: 40px !important; }
.container-top-md { margin-top: 50px !important; }
.container-top-lg { margin-top: 80px !important; }
.container-bottom-md { margin-bottom: 50px !important; }
.dashboard-form-container { padding: 40px 20px !important; }
.select-native { appearance: auto !important; padding-right: 10px !important; }
.caption-muted { font-size: 11.5px !important; color: var(--text-muted) !important; font-weight: 500 !important; }
.table-center { text-align: center !important; }
.w-25 { width: 25% !important; }
.w-50 { width: 50% !important; }
.w-75 { width: 75% !important; }
.section-card,
.form-grid-spaced,
.form-group-spaced,
.inline-section { margin-bottom: 24px !important; }
.inline-section-header { display: flex !important; justify-content: space-between !important; align-items: center !important; margin-bottom: 12px !important; border-bottom: 1px solid var(--card-border) !important; padding-bottom: 8px !important; }
.inline-section-title { margin: 0 !important; font-size: 15px !important; color: var(--text-main) !important; font-weight: 700 !important; }
.stacked-products { display: flex !important; flex-direction: column !important; gap: 0 !important; }
.textarea-compact { height: 80px !important; padding: 10px !important; resize: vertical !important; }
.btn-inline { margin-top: 0 !important; width: auto !important; }
.btn-list { height: 28px !important; padding: 0 16px !important; width: auto !important; font-size: 13px !important; }
.btn-edit { background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%) !important; }
.btn-danger { background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important; }
.btn-small { height: 32px !important; padding: 0 12px !important; width: auto !important; font-size: 12px !important; }
.filter-actions-flush { margin-top: 0 !important; margin-bottom: 0 !important; }
.filter-form-flex { display: flex !important; flex-wrap: wrap !important; gap: 16px !important; align-items: flex-end !important; }
.filter-field { flex: 1 !important; min-width: 150px !important; margin-bottom: 0 !important; }
.filter-field-wide { flex: 1.5 !important; min-width: 200px !important; margin-bottom: 0 !important; }
.btn-search-wide { height: 40px !important; padding: 0 24px !important; width: auto !important; white-space: nowrap !important; }
.card-header-actions { justify-content: space-between !important; }
.card-header-title { display: flex !important; align-items: center !important; gap: 12px !important; }

.dual-list-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.dual-list-column { display: flex; flex-direction: column; gap: 6px; }

.dual-list-select {
    height: 180px !important;
    padding: 8px !important;
    font-size: 13.5px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    outline: none;
}

.dual-list-select option { padding: 6px 10px; border-radius: 4px; margin-bottom: 2px; cursor: pointer; }
.dual-list-select option:hover { background-color: #f1f5f9; }
.dual-list-select option:checked { background-color: rgba(37, 99, 235, 0.08); color: #2563eb; }
.dual-list-actions { display: flex; flex-direction: column; gap: 8px; justify-content: center; padding-top: 20px; }

.btn-dual-list {
    background: #ffffff;
    border: 1px solid rgba(37, 99, 235, 0.08);
    color: #1e293b;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-dual-list:hover { background: rgba(37, 99, 235, 0.08); color: #2563eb; border-color: rgba(37, 99, 235, 0.2); }

.produto-linha {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important; /* Keep items on same line */
    align-items: center !important;
    gap: 12px !important;
    margin-bottom: 4px !important;
    padding: 3px 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
}

.produto-linha .form-group {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 0 !important;
}

/* Distribute flexible space: Código and Quantidade get equal space */
.produto-linha .form-group:first-of-type {
    flex: 1 1 0% !important;
}

.produto-linha .form-group:nth-of-type(2) {
    flex: 1 1 0% !important;
}

.produto-linha .form-label {
    margin: 0 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
}

/* Inputs stretch to occupy all remaining space within their groups */
.produto-linha .produto-codigo,
.produto-linha .produto-quantidade {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
}

.btn-remover-prod {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    border: none;
    border-radius: 6px;
    height: 28px !important;
    padding: 0 12px !important;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-remover-prod:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2); }

@media (max-width: 640px) {
    .dual-list-container { grid-template-columns: 1fr; }
    .dual-list-actions { flex-direction: row; padding-top: 0; }
    .btn-dual-list { transform: rotate(90deg); }
}

.btn-add-product-inline {
    margin-top: 0 !important;
    height: 32px !important;
    padding: 0 12px !important;
    width: auto !important;
    font-size: 12px !important;
}

.btn-small-strong {
    height: 32px !important;
    padding: 0 12px !important;
    width: auto !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}

.movimento-produtos-title {
    margin-bottom: 15px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--accent-primary) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.stacked-products-plain {
    display: flex !important;
    flex-direction: column !important;
}

.form-actions {
    flex-direction: row !important;
    align-items: stretch !important;
}

.form-actions > .btn-submit,
.form-actions > .btn-cancel {
    flex: 1 1 calc(50% - 10px) !important;
    min-width: 0 !important;
    width: auto !important;
}

#btn-add-produto,
#btn-adicionar-produto,
#produtos-container button,
.btn-remover-prod {
    height: 32px !important;
    padding: 0 12px !important;
    width: auto !important;
    font-size: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Impressão de relatórios: caber todas as colunas na mesma página */
@media print {
    @page {
        size: portrait;
        margin: 10mm;
    }

    body {
        background: none !important;
    }

    #cabecalho,
    .dashboard-card:has(form) {
        display: none !important;
    }

    .dashboard-container,
    .results-full-bleed {
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
        left: auto !important;
        transform: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .dashboard-card {
        box-shadow: none !important;
        border: none !important;
    }

    .table-container {
        overflow: visible !important;
        border: none !important;
    }

    .modern-table {
        width: 100% !important;
        table-layout: auto !important;
        font-size: 8pt !important;
    }

    .modern-table th,
    .modern-table td {
        padding: 2px 4px !important;
    }
}