:root{--orange:#f29129;--orange-hover:#e58414;--orange-dark:#b85f00;--ink:#29292e;--muted:#66666b;--line:#dbd6cc;--paper:#fff;--canvas:#f7f7f5;--info:#fff2de;--danger:#db3b38;--green:#167752;--sidebar:#333338;--sidebar-line:#4a4a50}
*{box-sizing:border-box}body{margin:0;background:var(--canvas);color:var(--ink);font-family:Inter,Segoe UI,Arial,sans-serif;font-size:14px;letter-spacing:0}.sidebar{position:fixed;inset:0 auto 0 0;width:230px;background:var(--sidebar);color:#fff;padding:18px 14px;display:flex;flex-direction:column}.brand{display:flex;align-items:center;gap:12px;padding:0 8px 20px;border-bottom:1px solid var(--sidebar-line)}.brand-mark{display:grid;place-items:center;width:52px;height:52px;background:#fff;border-radius:8px;overflow:hidden}.brand-mark img{display:block;width:100%;height:100%;object-fit:cover}.brand strong,.brand small{display:block}.brand strong{font-size:14px;letter-spacing:.4px}.brand small{color:#c1c1c5;margin-top:3px}.sidebar nav{display:grid;gap:5px;margin-top:20px}.nav-item{border:0;border-radius:6px;background:transparent;color:#d1d1d4;text-decoration:none;text-align:left;padding:11px 12px;display:flex;gap:10px;align-items:center;font:inherit;cursor:pointer;border-left:3px solid transparent}.nav-item:hover,.nav-item.active{background:#414147;color:#fff;border-color:var(--orange)}.connection{margin-top:auto;border-top:1px solid var(--sidebar-line);padding:18px 8px 0;color:#c1c1c5;font-size:12px;display:flex;gap:8px;align-items:center}.connection i{width:8px;height:8px;border-radius:50%;background:#45c58a;box-shadow:0 0 0 3px #45c58a22}main{margin-left:230px;min-width:900px}.topbar{height:94px;background:#fff;border-top:4px solid var(--orange);border-bottom:1px solid var(--line);padding:16px 26px 18px;display:flex;justify-content:space-between;align-items:center}.eyebrow{font-size:10px;font-weight:800;color:var(--orange-dark);margin:0 0 4px;text-transform:uppercase}.topbar h1,.modal h2{margin:0;font-size:25px}.top-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;white-space:nowrap}.top-actions>span{font-size:12px;color:var(--muted);margin:0}.top-actions .user-badge{padding:0 4px}.top-actions .icon-button{flex:0 0 40px}.top-actions #logoutButton{min-width:54px}button,select,input,textarea{font:inherit;letter-spacing:0}button{cursor:pointer}.primary,.secondary,.danger,.icon-button{height:40px;border:1px solid transparent;border-radius:6px;padding:0 14px;font-weight:700}.primary{background:var(--orange);color:var(--ink)}.primary:hover{background:var(--orange-hover)}.secondary{background:#fff;border-color:var(--line);color:var(--ink)}.secondary:hover{border-color:#aaa;background:#faf9f7}.danger{background:var(--danger);color:#fff}.icon-button{width:40px;padding:0;background:#fff;border-color:var(--line);font-size:20px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;padding:18px 26px 0}.metrics article{background:#fff;border:1px solid var(--line);border-radius:8px;padding:15px 16px;border-top:3px solid var(--orange);box-shadow:0 1px 2px #29292e0c}.metrics span,.metrics small{display:block;color:var(--muted);font-size:11px}.metrics strong{display:block;font-size:24px;margin:7px 0 3px}.workspace{margin:18px 26px 30px;background:#fff;border:1px solid var(--line);border-radius:8px;overflow:hidden;box-shadow:0 1px 2px #29292e0c}.toolbar{display:flex;gap:8px;padding:12px;border-bottom:1px solid var(--line);background:#fff}.search{flex:1;display:flex;align-items:center;border:1px solid var(--line);border-radius:6px;height:40px;padding:0 10px;gap:6px}.search:focus-within{border-color:var(--orange)}.search input{border:0;outline:0;width:100%}.toolbar select{height:40px;border:1px solid var(--line);border-radius:6px;background:#fff;padding:0 30px 0 10px}.table-summary{padding:9px 12px;display:flex;justify-content:space-between;color:var(--muted);font-size:11px;border-bottom:1px solid var(--line);background:var(--info)}.table-wrap{overflow:auto;max-height:calc(100vh - 300px)}table{border-collapse:separate;border-spacing:0;min-width:2500px;width:100%}th,td{padding:10px;border-bottom:1px solid #ecebea;border-right:1px solid #f1f0ee;text-align:left;white-space:nowrap;max-width:280px;overflow:hidden;text-overflow:ellipsis}th{position:sticky;top:0;background:#f8f7f4;z-index:2;font-size:11px;text-transform:uppercase;color:#555}tbody tr:hover td{background:#fff9f1}th.sticky,td.sticky{position:sticky;left:0;z-index:3;background:#fff}.row-actions{display:flex;gap:4px}.row-actions button{border:1px solid var(--line);border-radius:5px;background:#fff;width:30px;height:28px}.badge{display:inline-block;padding:4px 7px;border-radius:4px;font-size:11px;font-weight:800;background:var(--info);color:#8c4b00;border:1px solid #ffd49f}.empty-state{padding:50px;text-align:center;color:var(--muted)}dialog{border:0;padding:0;background:transparent;max-width:none}dialog::backdrop{background:#29292e99}.modal{background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 14px 50px #0004;max-height:90vh;overflow:auto}.modal.compact{width:min(460px,calc(100vw - 30px));padding:20px}.modal.medium{width:min(650px,calc(100vw - 30px));padding:20px}.modal.wide{width:min(1050px,calc(100vw - 30px));padding:22px}.modal header{display:flex;justify-content:space-between;align-items:flex-start;border-bottom:1px solid var(--line);padding-bottom:14px;margin-bottom:16px}.modal .close{border:0;font-size:24px;height:30px}.modal-copy{color:var(--muted);line-height:1.5}.modal label{display:grid;gap:5px;color:#555;font-size:12px;font-weight:700}.modal input,.modal select,.modal textarea,.inline-form input{width:100%;border:1px solid var(--line);border-radius:5px;background:#fff;padding:9px 10px;outline-color:var(--orange)}.modal input:focus,.modal select:focus,.modal textarea:focus,.inline-form input:focus{border-color:var(--orange)}.modal>form>label,.modal.compact label{margin:12px 0}.modal footer{display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--line);padding-top:15px;margin-top:18px}.form-section{border-bottom:1px solid var(--line);padding:0 0 18px;margin-bottom:18px}.form-section h3{font-size:13px;margin:0 0 12px}.form-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.span-2{grid-column:span 2}.span-3{grid-column:span 3}.inline-form{display:flex;gap:8px;padding-bottom:16px;border-bottom:1px solid var(--line)}.billing-list{margin-top:8px}.billing-item{display:flex;align-items:center;justify-content:space-between;padding:10px 4px;border-bottom:1px solid var(--line)}.billing-item small{color:var(--muted);margin-left:8px}.billing-item .inactive{text-decoration:line-through;color:var(--muted)}#toast{position:fixed;right:20px;bottom:20px;background:var(--ink);color:#fff;padding:12px 16px;border-radius:6px;box-shadow:0 5px 20px #0004;opacity:0;transform:translateY(8px);transition:.2s;pointer-events:none;z-index:20}#toast.show{opacity:1;transform:none}#toast.error{background:var(--danger)}
@media(max-width:900px){.sidebar{width:64px}.sidebar .brand div,.sidebar .nav-item:not(.active){font-size:0}.sidebar .nav-item span{font-size:16px}.connection span{display:none}main{margin-left:64px;min-width:760px}.metrics{grid-template-columns:repeat(2,1fr)}}
.save-error td{background:#fff5f5}.save-error:hover td{background:#ffecec}.save-error .error-value{color:var(--danger);font-weight:800}.save-error td.sticky{background:#fff5f5}
.refresh-errors{border-color:var(--danger);color:var(--danger);white-space:nowrap}.refresh-errors:hover{background:#fff5f5;border-color:var(--danger)}.refresh-errors:disabled{opacity:.55;cursor:wait}
.refresh-log-summary{display:flex;justify-content:space-between;gap:16px;padding:14px;border-radius:6px;background:var(--info);margin-bottom:12px}.refresh-log-summary strong,.refresh-log-summary span{display:block}.refresh-log-list{display:grid;gap:8px;max-height:48vh;overflow:auto}.refresh-log-list>div{display:grid;gap:4px;padding:10px 12px;border:1px solid var(--line);border-left:4px solid var(--green);border-radius:6px}.refresh-log-list>div.failure{border-left-color:var(--danger);background:#fff5f5}.refresh-log-list strong{font-size:12px;word-break:break-all}.refresh-log-list span{font-size:12px;color:var(--muted)}.empty-log{text-align:center;color:var(--muted)}

#loginDialog[open] {
    display: block;
}
#loginDialog::backdrop{background:rgba(0,0,0,.55)}
#loginDialog .modal{
    width:min(420px,100%);
    max-width:420px;

    background:#f7d99afd;
    border-top:4px solid #f29129;

    box-shadow:0 14px 50px rgba(0,0,0,.15);
}
#loginDialog .modal header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 14px;
    margin-bottom: 16px;
}

#loginDialog .modal header > div {
    width: 100%;
    text-align: center;
}

#loginDialog .modal header .eyebrow {
    text-align: center;
}

#loginDialog .modal header h2 {
    text-align: center;
}
#loginDialog .modal-copy{margin:0 0 22px;color:#555;line-height:1.6;}
#loginDialog label{display:grid;gap:6px;font-size:12px;font-weight:700;color:#333;margin-bottom:14px}
#loginDialog input{width:100%;border:1px solid var(--line);border-radius:6px;padding:12px 14px;background:#fff;outline-color:var(--orange)}
#loginDialog footer{display:flex;justify-content:flex-end;gap:8px;border-top:1px solid var(--line);padding-top:15px;margin-top:18px}
#loginDialog button.primary{width:100%;}
.login-error{color:var(--danger);margin-top:8px;font-size:13px;min-height:18px}
.user-badge{font-size:12px;color:var(--muted);padding:0 8px;white-space:nowrap}
body:not(.authenticated) main,body:not(.authenticated) .sidebar{pointer-events:none;user-select:none;filter:blur(1px)}

.modal.xlarge{width:min(1200px,calc(100vw - 30px));padding:26px}
.modal.maximized{position:fixed;inset:0;margin:0;width:100vw;height:100vh;max-width:none;max-height:none;border-radius:0;padding:26px;z-index:9999;display:flex;flex-direction:column}
.modal-actions{display:flex;gap:8px;align-items:center}
.report-export-actions{display:flex;gap:10px;align-items:center}.report-export-actions .secondary{white-space:nowrap}.report-export-actions .export-pdf{border-color:#d84a45;color:#b8322e}.report-export-actions .export-pdf:hover{background:#fff3f2;border-color:#d84a45}.report-export-actions .export-excel{border-color:#28865c;color:#176b45}.report-export-actions .export-excel:hover{background:#effaf4;border-color:#28865c}.report-export-actions button:disabled{opacity:.55;cursor:wait}
.reports-scroll{flex:1;min-height:0;overflow:auto;padding-right:4px}.reports-container{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:22px;min-height:600px}
.period-report{display:grid;grid-template-rows:auto minmax(280px,1fr) auto;gap:16px;padding:18px;background:#faf9f7;border:1px solid var(--line);border-radius:12px;min-height:0}
.period-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
.period-heading span,.period-heading strong,.period-heading small{display:block}.period-heading span{font-size:11px;font-weight:800;color:var(--orange-dark);margin-bottom:5px}.period-heading strong{font-size:16px}.period-heading small{max-width:210px;text-align:right;color:var(--muted);line-height:1.4}
.chart-box{position:relative;min-height:280px;background:#fff;border:1px solid #ece8e0;border-radius:10px;padding:10px}.chart-box canvas{width:100%!important;height:100%!important}.chart-empty{position:absolute;inset:0;display:grid;place-items:center;padding:30px;text-align:center;color:var(--muted)}.chart-empty[hidden]{display:none}
.period-totals{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.period-totals div{padding:14px;background:#fff;border:1px solid var(--line);border-left:4px solid var(--orange);border-radius:8px}.period-totals span,.period-totals strong{display:block}.period-totals span{font-size:11px;color:var(--muted);margin-bottom:5px}.period-totals strong{font-size:20px}
.material-report{margin-top:24px;padding:20px;background:#faf9f7;border:1px solid var(--line);border-radius:12px}.material-report-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;margin-bottom:18px}.material-report-heading h3{margin:0;font-size:21px}.material-summary{display:flex;gap:8px}.material-summary span{padding:8px 12px;background:var(--info);border:1px solid #ffd49f;border-radius:6px;font-weight:800;color:#8c4b00}.material-filters{display:grid;grid-template-columns:minmax(220px,1fr) minmax(220px,1fr) auto;align-items:end;gap:14px;margin-bottom:20px}.material-filters label{display:grid;gap:6px;font-size:12px;font-weight:700}.material-filters input{height:40px;border:1px solid var(--line);border-radius:6px;background:#fff;padding:0 10px}.material-table-wrap{position:relative;overflow:auto;border:1px solid var(--line);border-radius:8px;background:#fff;min-height:110px}.material-table{min-width:0;width:100%;border-spacing:0}.material-table th,.material-table td{max-width:none;text-align:center;padding:11px 14px}.material-table th:first-child,.material-table td:first-child{text-align:left}.material-table th{position:static;background:var(--info);font-size:12px}.material-table tbody tr:last-child td{border-bottom:0}.material-empty{padding:32px;text-align:center;color:var(--muted)}.material-empty[hidden]{display:none}
.sector-table{min-width:980px}.sector-table th:first-child,.sector-table td:first-child{min-width:260px}.sector-table th:not(:first-child),.sector-table td:not(:first-child){min-width:170px}
.receipt-filters{display:grid;grid-template-columns:minmax(190px,1fr) minmax(190px,1fr) minmax(240px,1.2fr) auto;align-items:end;gap:14px;margin-bottom:20px}.receipt-filters label{display:grid;gap:6px;font-size:12px;font-weight:700}.receipt-filters input,.receipt-filters select{height:40px;border:1px solid var(--line);border-radius:6px;background:#fff;padding:0 10px}.receipt-charts{display:grid;grid-template-columns:minmax(0,3fr) minmax(300px,1fr);gap:18px}.receipt-chart-box{position:relative;height:390px;padding:12px;background:#fff;border:1px solid var(--line);border-radius:10px}.receipt-chart-box canvas{width:100%!important;height:100%!important}.receipt-doughnut{min-width:300px}
#reportsModalSection>footer{margin-top:16px}
@media(max-width:1000px){.reports-container{grid-template-columns:1fr}.period-report{min-height:620px}.modal.xlarge{width:min(98vw,calc(100vw - 20px));padding:18px}.period-heading{display:block}.period-heading small{text-align:left;max-width:none;margin-top:6px}.material-filters,.receipt-filters{grid-template-columns:1fr}.material-report-heading{display:block}.material-summary{margin-top:12px}.receipt-charts{grid-template-columns:1fr}.receipt-doughnut{min-width:0}}
.material-summary{flex-wrap:wrap;justify-content:flex-end}
.login-signature {
    display: flex;
    justify-content: center;
    align-items: center;

    margin-top: 12px;
    padding-top: 10px;

    opacity: 0.55;
}

.login-signature img {
    width: 85px;
    height: auto;
    display: block;
}
.sidebar-footer {
    background: #f8f7f4;
    margin: 10px -14px -18px -14px;
    padding: 5px 10px;

    display: flex;
    justify-content: center;
    align-items: center;

    border-top: 1px solid #d8d8d8;
}

.sidebar-footer img {
    width: 110px;
    height: auto;
    opacity: .75;
}
.login-logo {
    text-align: center;
    margin-bottom: 12px;
}

.login-logo img {
    width: 65px;
    height: 65px;
    border-radius: 8px;
    object-fit: cover;
}

.toolbar .flag-filter {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 0;
    background: transparent;
    padding: 6px 4px 0;
    font-weight: 700;
    white-space: nowrap;
    transform: translateY(2px);
}

.toolbar .flag-filter input {
    width: 16px;
    height: 16px;
    accent-color: var(--orange);
    cursor: pointer;
    margin: 0;
}

.toolbar .flag-filter span {
    cursor: pointer;
}

.toolbar .flag-filter:has(input:checked) {
    color: var(--orange-dark);
}

.toolbar .date-filter {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 0 10px;
    white-space: nowrap;
}

.toolbar .date-filter span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.toolbar .date-filter input {
    width: 138px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.toolbar .date-filter:focus-within {
    border-color: var(--orange);
}

.toolbar #downloadAll,
.toolbar #downloadTableExcel {
    background: #fff2de;
    border-color: #f4c78f;
    color: #7a4300;
}

.toolbar #downloadAll:hover,
.toolbar #downloadTableExcel:hover {
    background: #ffe8c4;
    border-color: #eeb46e;
}

.chart-box,
.receipt-chart-box {
    background:
        radial-gradient(circle at 14% 10%, rgba(255,255,255,.9), transparent 36%),
        linear-gradient(135deg, #eef6ff 0%, #fbfdff 46%, #d8e5f0 100%);
    border-color: #c6d6e2;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 10px 26px rgba(41,62,82,.12);
}

.reports-container {
    min-height: 0;
    align-items: start;
}

.period-report {
    grid-template-rows: auto 360px auto;
}

.toolbar {
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar .search {
    flex: 999 1 360px;
    min-width: 300px;
}

.toolbar .date-filter {
    flex: 0 1 172px;
    padding: 0 8px;
}

.toolbar .date-filter input {
    width: 102px;
}

.toolbar select {
    flex: 0 1 150px;
    min-width: 142px;
    padding-right: 28px;
}

.toolbar #downloadAll,
.toolbar #downloadTableExcel {
    flex: 0 0 136px;
}

.metrics {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    padding-top: 10px;
    gap: 10px;
}

.metrics article {
    padding: 10px 14px;
    min-height: 74px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.metrics strong {
    font-size: 22px;
    margin: 4px 0 1px;
}

.top-actions .export-action {
    flex: 0 0 112px;
    width: 112px;
    height: 36px;
    padding: 0 8px;
    background: #fff2de;
    border-color: #f4c78f;
    color: #7a4300;
    font-size: 12px;
}

.top-actions .export-action:hover {
    background: #ffe8c4;
    border-color: #eeb46e;
}

.toolbar {
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
}

.toolbar .search {
    flex: 1 1 390px;
    min-width: 300px;
    height: 36px;
}

.toolbar .flag-filter {
    height: 36px;
    padding-top: 2px;
    flex: 0 0 auto;
}

.toolbar .date-filter {
    height: 36px;
    flex: 0 0 154px;
    gap: 5px;
    padding: 0 7px;
}

.toolbar .date-filter span {
    font-size: 11px;
}

.toolbar .date-filter input {
    width: 86px;
    font-size: 12px;
}

.toolbar select {
    height: 36px;
    flex: 0 0 134px;
    min-width: 124px;
    padding: 0 22px 0 8px;
    font-size: 12px;
}

.toolbar #billingFilter {
    flex-basis: 116px;
    min-width: 106px;
}

.workspace {
    margin-top: 10px;
}

.table-wrap {
    max-height: calc(100vh - 226px);
}

th,
td {
    padding: 8px 9px;
}

tbody td {
    font-size: 13px;
}

tbody tr:nth-child(even) td {
    background: #fffdf9;
}

tbody tr:hover td {
    background: #fff4e3;
}

.period-report .chart-box {
    min-height: 0;
    height: 360px;
}

.batch-result-summary {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.batch-result-summary strong,
.batch-result-summary span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #faf9f7;
}

.batch-result-list {
    max-height: 300px;
    overflow: auto;
    display: grid;
    gap: 8px;
}

.batch-result-list div {
    border: 1px solid var(--line);
    border-left: 4px solid #76818d;
    border-radius: 6px;
    padding: 9px 10px;
    background: #fff;
}

.batch-result-list strong,
.batch-result-list span {
    display: block;
}

.batch-result-list span {
    color: var(--muted);
    margin-top: 3px;
}

.batch-result-list .cadastrada {
    border-left-color: #48a868;
}

.batch-result-list .erro {
    border-left-color: var(--danger);
    background: #fff5f5;
}

.batch-result-list .duplicada {
    border-left-color: #e0b43c;
}

.top-actions #openBatchScan {
    width: 145px;
    min-width: 145px;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: #fffaf1;
    font-size: 12px;
}

.table-pagination label,
.pagination-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-pagination select {
    height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 0 8px;
}

.pagination-actions .secondary {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.pagination-actions .secondary:disabled {
    opacity: .45;
    cursor: not-allowed;
}

#tablePageInfo {
    min-width: 98px;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}

@media(max-width:1000px){
    .period-report {
        min-height: 0;
        grid-template-rows: auto 340px auto;
    }

    .period-report .chart-box {
        height: 340px;
    }
}
