:root {
    --primary: #FF7A00;
    --primary-hover: #E66E00;
    --bg-light: #F8F9FA;
    --card-bg: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #6C757D;
    --border-color: #E9ECEF;
    --shadow: 0 8px 24px rgba(255, 122, 0, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-light);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* NAVEGAÇÃO ENTRE PÁGINAS */
.page {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page.active {
    display: flex;
    opacity: 1;
    z-index: 10;
}

/* LOGIN PAGE */
#page-login {
    background: linear-gradient(135deg, #1A1A1A 0%, #333 100%);
    background-size: cover;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    perspective: 1000px;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 50px 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.brand {
    margin-bottom: 35px;
}

.brand h1 {
    color: var(--text-main);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-top: 10px;
}

.brand span {
    color: var(--primary);
}

.login-logo {
    width: 110px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(255, 122, 0, 0.2));
}

.company-phrase {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 10px;
    letter-spacing: 0.2px;
}

.field {
    text-align: left;
    margin-bottom: 24px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    background: #FFF;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 122, 0, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 122, 0, 0.4);
}

.error-msg {
    color: #E63946;
    font-size: 13px;
    margin-top: 18px;
    font-weight: 600;
}

/* HEADERBAR */
.natan-bar {
    background: var(--card-bg);
    color: var(--text-main);
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.bar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 800;
    font-size: 15px;
    color: var(--primary);
}

.bar-right {
    display: flex;
    align-items: center;
    gap: 25px;
    font-size: 13px;
    font-weight: 500;
}

.btn-logout {
    background: #F8F9FA;
    border: 1.5px solid #E63946;
    color: #E63946;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #E63946;
    color: white;
}

/* FILTERS PAGE */
.content-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.card-filters {
    background: var(--card-bg);
    width: 100%;
    max-width: 1100px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 45px;
    border-top: 6px solid var(--primary);
}

.card-title {
    font-weight: 800;
    color: var(--text-main);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 35px;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 380px 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 25px;
    grid-template-areas: 
        "filial ini fim"
        "filial fornec fornec";
}

.filial-item-box { grid-area: filial; }
.dt-ini-box { grid-area: ini; }
.dt-fim-box { grid-area: fim; }
.fornec-box { grid-area: fornec; }

.filter-item label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.filter-item input {
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-item input:focus {
    border-color: var(--primary);
}

.multi-select-box {
    background: #FCFDFE;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    height: 250px;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
}

.filial-item {
    background: white;
    border: 1.5px solid var(--border-color);
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-main);
}

.filial-item:hover {
    border-color: var(--primary);
    background: rgba(255, 122, 0, 0.05);
}

.filial-item.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(255, 122, 0, 0.3);
}

.btn-execute {
    width: 100%;
    margin-top: 40px;
    padding: 20px;
    background: var(--text-main);
    color: white;
    border: none;
    font-weight: 800;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-execute:hover {
    background: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(255, 122, 0, 0.3);
}

/* LIMIT BAR */
.limit-bar {
    padding: 10px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-limit {
    padding: 6px 14px;
    border: 1.5px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-limit.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 3px 8px rgba(255, 122, 0, 0.25);
}

.btn-limit:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

/* RESULTS PAGE */
#page-results {
    background: var(--card-bg);
}

.btn-back {
    background: #F1F3F5;
    color: var(--text-main);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-back:hover {
    background: #E9ECEF;
}

/* REPORT SELECTOR IN FILTERS */
.report-selector-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 25px;
    background: #f1f3f5;
    padding: 8px;
    border-radius: 12px;
}

.btn-report-type {
    padding: 10px;
    border: none;
    background: white;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-report-type.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(255, 122, 0, 0.2);
}

.btn-report-type:hover:not(.active) {
    background: rgba(255, 122, 0, 0.1);
    color: var(--primary);
}

.report-badge {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(255, 122, 0, 0.2);
}

.results-header {
    background: #FFF;
    border-bottom: 2px solid #f1f3f5;
}

.btn-export {
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-excel {
    background: #2D6A4F;
    box-shadow: 0 4px 10px rgba(45, 106, 79, 0.2);
}

.btn-pdf {
    background: #BC4749;
    box-shadow: 0 4px 10px rgba(188, 71, 73, 0.2);
}

.table-area {
    flex: 1;
    overflow: hidden;
    padding: 0 30px;
    display: flex;
    flex-direction: column;
}

.table-scroll {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:nth-child(even) {
    background-color: #FAFBFC;
}

tr:hover {
    background-color: rgba(255, 122, 0, 0.05);
}

.natan-footer {
    background: #1A1A1A;
    color: white;
    padding: 0 40px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    border-top: 3px solid var(--primary);
}

.f-stat div {
    font-size: 11px;
    color: #ADB5BD;
    text-transform: uppercase;
    font-weight: 700;
    margin-right: 15px;
    display: inline-block;
}

.f-stat span {
    font-weight: 800;
    font-size: 20px;
    color: var(--primary);
}

/* LOADER */
.natan-loader {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(5px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite cubic-bezier(0.5, 0, 0.5, 1);
    margin-bottom: 25px;
}

.natan-loader p {
    color: white;
    font-weight: 800;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== CONSULTA DE ESTOQUE ===== */
#page-consulta {
    background: var(--bg-light);
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
    padding: 20px 30px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.search-field label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.search-field input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.1);
}

.search-filiais { flex: 1 1 100%; }
.search-codigo { flex: 0 0 160px; }
.search-descricao { flex: 1 1 320px; }

.filial-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.filial-chip {
    background: white;
    border: 1.5px solid var(--border-color);
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.filial-chip:hover {
    border-color: var(--primary);
    background: rgba(255, 122, 0, 0.05);
}

.filial-chip.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(255, 122, 0, 0.3);
}

.search-actions {
    display: flex;
    gap: 10px;
}

.btn-search {
    padding: 13px 28px;
    background: var(--text-main);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-search:hover {
    background: var(--primary);
    box-shadow: 0 6px 16px rgba(255, 122, 0, 0.3);
}

.btn-clear {
    padding: 13px 16px;
    background: #F1F3F5;
    color: #E63946;
    border: 1.5px solid #DEE2E6;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #E63946;
    color: white;
    border-color: #E63946;
}

.result-info {
    padding: 0 30px;
    font-size: 12px;
    font-weight: 700;
    color: #E67700;
}

.result-info:not(:empty) {
    padding-top: 10px;
}

#page-consulta .table-area {
    padding-top: 16px;
    padding-bottom: 0;
    background: var(--bg-light);
}

#page-consulta .table-scroll {
    background: white;
}

#main-table th {
    cursor: pointer;
    white-space: nowrap;
}

#main-table td {
    padding: 12px 15px;
}

#main-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#main-table td.cod { font-weight: 800; color: var(--primary); }
#main-table td.est-ok { font-weight: 700; color: #2F9E44; }
#main-table td.est-zero { color: #ADB5BD; }
#main-table td.est-neg { font-weight: 800; color: #E03131; }

.empty-row {
    text-align: center;
    padding: 60px !important;
    color: #ADB5BD !important;
}

.natan-footer .btn-export {
    padding: 8px 20px;
    font-size: 12px;
}

.natan-footer .f-stat div { margin-right: 12px; }

/* ===== EMISSÃO DE ETIQUETAS: busca, parâmetros e fila ===== */
#page-etiquetas {
    background: var(--bg-light);
}

.search-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.1);
}

.search-filial { flex: 0 1 280px; }
.search-busca { flex: 1 1 360px; }

.etq-params {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
    padding: 14px 30px;
    background: #FFF7EE;
    border-bottom: 1px solid var(--border-color);
}

.etq-params .search-field { flex: 0 1 340px; }
.etq-params .search-field.etq-num { flex: 0 0 150px; }

.etq-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
    padding: 16px 30px;
}

.etq-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.etq-panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.etq-panel .table-scroll {
    background: white;
    border-radius: 12px;
}

.etq-panel th,
.etq-panel td {
    padding: 10px 12px;
    white-space: nowrap;
}

.etq-panel td:nth-child(3),
#fila-table td:first-child {
    white-space: normal;
}

.etq-panel .num { text-align: right; font-variant-numeric: tabular-nums; }
.etq-panel td.cod { font-weight: 800; color: var(--primary); }
.etq-panel td.preco { font-weight: 800; }
.etq-panel td.pix { font-weight: 800; color: #E03131; }
.etq-panel td.sem-preco { font-weight: 800; font-size: 11px; color: #E03131; }

.fila-desc { font-weight: 700; }
.fila-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.btn-add {
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-add:hover:not(:disabled) { background: var(--primary-hover); }
.btn-add:disabled { background: #DEE2E6; cursor: not-allowed; }

.btn-del {
    background: none;
    border: none;
    color: #E63946;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.btn-clear-fila {
    background: none;
    border: 1.5px solid #E63946;
    color: #E63946;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.btn-clear-fila:hover { background: #E63946; color: white; }

.natan-footer .btn-export:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 900px) {
    .etq-body { grid-template-columns: 1fr; overflow: auto; }
    .etq-panel .table-scroll { max-height: 55vh; }
}

.btn-diag {
    padding: 13px 18px;
    background: white;
    color: var(--text-main);
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.btn-diag:hover { border-color: var(--primary); color: var(--primary); }

.diag-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
}

.diag-box {
    width: min(900px, 92vw);
    height: min(640px, 85vh);
    display: flex;
    flex-direction: column;
    padding: 18px 20px;
    background: white;
    border-radius: 12px;
}

.diag-box textarea {
    flex: 1;
    resize: none;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
}

.folhas-box { width: min(980px, 94vw); height: min(620px, 88vh); }
.folhas-corpo { flex: 1; min-height: 0; display: flex; gap: 18px; overflow: auto; }
.folhas-lista { flex: 0 0 280px; display: flex; flex-direction: column; gap: 10px; }
.folhas-lista select { flex: 1; padding: 6px; border: 1.5px solid var(--border-color); border-radius: 8px; font-size: 13px; }
.folhas-form { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-content: start; }
.folhas-form .fo-nome { grid-column: 1 / -1; }
.fo-botoes { grid-column: 1 / -1; display: flex; gap: 10px; }
.fo-botoes .btn-add { padding: 11px 26px; font-size: 12px; }
@media (max-width: 760px) { .folhas-corpo { flex-direction: column; } .folhas-lista { flex-basis: auto; } }
