:root {
    --bg: #eef2f6;
    --panel: #ffffff;
    --text: #23313f;
    --muted: #687787;
    --border: #d8e0e7;
    --accent: #1f5b8f;
    --accent-dark: #184a76;
    --success-bg: #eef7f0;
    --danger: #a52a2a;
    --danger-bg: #fff0f0;
    --warning-bg: #fff8e7;
}

* {
    box-sizing: border-box;
}

html {
    font-family:
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    margin: 0;
    min-width: 320px;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 24px;
    background: #172433;
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark,
.login-logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #fff;
    color: #172433;
    font-weight: 800;
    font-size: 21px;
}

.brand div:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand span {
    font-size: 12px;
    opacity: .72;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topnav a,
.link-button {
    color: #fff;
    text-decoration: none;
    background: transparent;
    border: 0;
    padding: 8px 0;
    cursor: pointer;
}

.page {
    width: min(1600px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 40px;
}

.page-head,
.table-head,
.print-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head h1,
.table-head h2 {
    margin: 0;
}

.page-head p,
.table-head p {
    margin: 4px 0 0;
}

.head-actions,
.filter-buttons,
.quick-periods,
.print-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 7px 12px;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    border-color: #aebdca;
}

.button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-dark);
}

.button.ghost {
    background: transparent;
}

.button.full {
    width: 100%;
}

.filters,
.table-panel {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
}

.filter-grid {
    display: grid;
    grid-template-columns:
        1fr .65fr
        1fr .65fr
        .75fr .85fr
        1.5fr 1fr 1fr;
    gap: 10px;
    align-items: end;
}

.field {
    min-width: 0;
}

.field label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #455565;
}

.field input,
.login-form input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 9px;
    color: var(--text);
    background: #fff;
}

.field input:focus,
.login-form input:focus {
    outline: 2px solid rgba(31, 91, 143, .18);
    border-color: var(--accent);
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.summary-card,
.operation-grid article {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel);
    padding: 13px;
    min-width: 0;
}

.summary-card span,
.operation-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 19px;
    overflow-wrap: anywhere;
}

.operation-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.operation-grid strong {
    display: block;
    margin-top: 4px;
    font-size: 17px;
}

.table-scroll {
    overflow-x: auto;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    min-width: 1450px;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f3f6f8;
    color: #435261;
    text-align: left;
    font-weight: 700;
}

.data-table th,
.data-table td {
    padding: 8px 9px;
    border-bottom: 1px solid #e6ebef;
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: #f8fbfd;
}

.number {
    text-align: right !important;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 24px !important;
}

.table-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding-top: 14px;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.alert {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.alert.error {
    color: #8b1e1e;
    background: var(--danger-bg);
    border-color: #e3bcbc;
}

.alert.success {
    background: var(--success-bg);
}

.login-body {
    background: #e8edf2;
}

.login-body .page {
    width: 100%;
    padding: 0;
}

.login-shell {
    min-height: 620px;
    display: grid;
    place-items: center;
    padding: 28px 16px;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.login-card h1 {
    margin: 14px 0 0;
}

.login-card > .muted {
    margin-top: 4px;
}

.login-form {
    margin-top: 22px;
}

.login-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
}

.login-form .button {
    margin-top: 12px;
}

.login-note {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.print-page {
    background: #dfe5ea;
}

.print-page .page {
    width: min(1500px, calc(100% - 24px));
}

.print-toolbar {
    justify-content: flex-end;
    margin-bottom: 12px;
}

.print-sheet {
    margin: 0 auto;
    background: #fff;
    color: #111;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.print-sheet.portrait,
.ticket-sheet {
    width: 210mm;
    min-height: 297mm;
    padding: 12mm;
    page: portrait-page;
}

.print-sheet.landscape {
    width: 297mm;
    min-height: 210mm;
    padding: 8mm;
    page: landscape-page;
}

.print-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 2px solid #222;
    padding-bottom: 7px;
    margin-bottom: 8px;
}

.print-header > div:first-child {
    display: flex;
    flex-direction: column;
}

.print-header strong {
    font-size: 17px;
}

.print-header span {
    font-size: 11px;
}

.print-meta {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.print-filter {
    padding: 7px 8px;
    margin-bottom: 10px;
    background: #f2f2f2;
    border: 1px solid #ddd;
    font-size: 9.5px;
}

.print-sheet h2 {
    margin: 13px 0 6px;
    font-size: 12px;
    text-transform: uppercase;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8px;
}

.print-table th,
.print-table td {
    border: 1px solid #b8b8b8;
    padding: 3px 4px;
    vertical-align: top;
}

.print-table th {
    background: #ededed;
    font-weight: 700;
    text-align: left;
}

.summary-table {
    font-size: 10px;
}

.summary-table th {
    width: 70%;
}

.summary-table td {
    text-align: right;
    font-weight: 700;
}

.detailed-print {
    table-layout: auto;
}

.print-warning {
    border: 1px solid #c69b34;
    background: var(--warning-bg);
    padding: 6px;
    margin-bottom: 8px;
    font-size: 9px;
}

.print-footer {
    margin-top: 10px;
    padding-top: 5px;
    border-top: 1px solid #bbb;
    color: #555;
    font-size: 8px;
}

.ticket-header {
    align-items: center;
}

.ticket-number {
    font-size: 18px;
    font-weight: 800;
}

.cancel-banner,
.repesagem-banner {
    margin: 8px 0;
    border: 2px solid var(--danger);
    color: var(--danger);
    padding: 7px;
    text-align: center;
    font-weight: 800;
}

.repesagem-banner {
    border-color: #806515;
    color: #69530f;
    background: #fff9df;
}

.ticket-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
    margin-top: 10px;
}

.ticket-grid > div {
    border-bottom: 1px solid #ddd;
    padding: 5px 2px;
}

.ticket-grid span,
.weight-boxes span {
    display: block;
    font-size: 8px;
    color: #666;
    text-transform: uppercase;
}

.ticket-grid strong {
    display: block;
    margin-top: 2px;
    font-size: 10px;
}

.weight-boxes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin-top: 14px;
}

.weight-boxes > div {
    border: 1px solid #888;
    padding: 8px;
    text-align: center;
}

.weight-boxes strong {
    display: block;
    margin-top: 3px;
    font-size: 14px;
}

.ticket-notes {
    margin-top: 12px;
    padding: 8px;
    border: 1px solid #ddd;
    font-size: 9px;
}

.ticket-notes p {
    margin: 3px 0;
}

.cancel-text {
    border-color: #c78c8c;
}

@page portrait-page {
    size: A4 portrait;
    margin: 0;
}

@page landscape-page {
    size: A4 landscape;
    margin: 0;
}

@media (max-width: 1150px) {
    .filter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .summary-grid,
    .operation-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .topbar {
        padding: 10px 14px;
    }

    .page {
        width: min(100% - 20px, 1600px);
        padding-top: 14px;
    }

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

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

    .head-actions,
    .filter-buttons {
        width: 100%;
    }

    .head-actions .button,
    .filter-buttons .button {
        flex: 1 1 auto;
    }
}

@media (max-width: 430px) {
    .filter-grid,
    .summary-grid,
    .operation-grid {
        grid-template-columns: 1fr;
    }

    .topnav > a {
        display: none;
    }
}

@media print {
    html,
    body,
    .print-page,
    .print-page .page {
        background: #fff !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .no-print,
    .topbar {
        display: none !important;
    }

    .print-sheet {
        margin: 0 !important;
        box-shadow: none !important;
    }

    .print-sheet.portrait,
    .ticket-sheet {
        width: 210mm;
        min-height: 0;
    }

    .print-sheet.landscape {
        width: 297mm;
        min-height: 0;
    }

    .print-table thead {
        display: table-header-group;
    }

    .print-table tr {
        break-inside: avoid;
    }
}

/* Update 017 — usuários humanos do Portal */
.hp-field{position:absolute!important;left:-10000px!important;width:1px!important;height:1px!important;overflow:hidden!important}
.human-box{border:1px solid #c9d8e5;background:#f5f9fc;border-radius:8px;padding:12px;margin-top:4px}.human-box p{margin:6px 0 10px}
.user-pill{display:inline-flex;align-items:center;padding:5px 9px;border:1px solid rgba(255,255,255,.22);border-radius:999px;font-size:12px;color:#fff;white-space:nowrap}
.form-card{background:#fff;border:1px solid var(--border);border-radius:12px;padding:18px;max-width:900px}.form-card.narrow{max-width:560px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.form-card .field{margin-bottom:12px}.form-card .field label{display:block;font-weight:650;margin-bottom:5px}.form-card .field input,.form-card .field select{width:100%;min-height:42px;border:1px solid var(--border);border-radius:8px;padding:8px 10px;background:#fff;font:inherit}.form-card .field small{display:block;color:var(--muted);margin-top:5px}.check-field{display:flex;align-items:end}.check-field label{display:flex!important;align-items:center;gap:8px}.check-field input{width:auto!important;min-height:auto!important}
.data-table{width:100%;border-collapse:collapse;min-width:900px;background:#fff}.data-table th,.data-table td{padding:10px;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle;font-size:13px}.data-table th{background:#f3f6f8}.row-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.row-actions form{margin:0}.button.small{min-height:34px;padding:5px 9px;font-size:12px}.profile-badge{display:inline-block;padding:3px 7px;border-radius:999px;background:#edf2f6;font-size:11px;font-weight:700}.permission-help{margin-top:14px;padding:14px;border:1px solid var(--border);border-radius:10px;background:#fff}.permission-help h2{margin:0 0 4px;font-size:16px}.permission-help p{margin:0;color:var(--muted)}
.secret-box{margin:12px 0;padding:18px;border:2px solid #1f5b8f;border-radius:10px;background:#fff}.secret-box span,.secret-box small{display:block;color:var(--muted)}.secret-box strong{display:block;font:700 22px Consolas,monospace;letter-spacing:.4px;margin:8px 0;word-break:break-all}
@media(max-width:800px){.form-grid{grid-template-columns:1fr}.user-pill{display:none}}

/* Update 018.1.6 — impressão online alinhada ao Desktop */
.desktop-report-sheet {
    font-family: Arial, Helvetica, sans-serif;
    color: #000;
}

.desktop-company-header {
    display: flex;
    align-items: flex-start;
    gap: 4mm;
    min-height: 27mm;
    margin: 0 0 3mm;
    padding: 0;
    border: 0;
}

.desktop-company-logo {
    width: 25mm;
    height: 25mm;
    flex: 0 0 25mm;
    display: flex;
    align-items: center;
    justify-content: center;
    border: .2mm solid #dedede;
    background: #fff;
    overflow: hidden;
}

.desktop-company-logo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.desktop-company-text {
    padding-top: .6mm;
    line-height: 1.22;
}

.desktop-company-name {
    margin-bottom: 1mm;
    font-size: 11pt;
    line-height: 1.05;
    font-weight: 700;
}

.desktop-company-line {
    margin: .25mm 0;
    font-size: 6.6pt;
    line-height: 1.25;
}

.desktop-report-title {
    margin: 1mm 0 3mm;
    padding: 0;
    text-align: center;
    font-size: 10.5pt;
    line-height: 1.1;
    font-weight: 700;
    text-transform: uppercase;
}

.desktop-report-filter {
    margin: 0 0 2mm;
    padding: 0;
    background: transparent;
    border: 0;
    font-size: 5.9pt;
    line-height: 1.35;
}

.desktop-section-title {
    margin: 2.5mm 0 0;
    padding: 1.1mm 1.4mm;
    background: #eef1f4;
    font-size: 6.4pt;
    line-height: 1.15;
    font-weight: 700;
}

.desktop-section-gap {
    margin-top: 3mm;
}

.desktop-summary-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 6.3pt;
}

.desktop-summary-table td {
    padding: 1.2mm 1.6mm;
    border: .2mm solid #d7d7d7;
    vertical-align: middle;
}

.desktop-summary-table td:first-child {
    width: 52%;
}

.desktop-summary-table td:last-child {
    text-align: right;
    font-weight: 700;
}

.desktop-report-note {
    margin: 4mm 0 0;
    color: #777;
    font-size: 5.8pt;
    font-style: italic;
}

.desktop-detail-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 5.35pt;
    line-height: 1.15;
}

.desktop-detail-table th,
.desktop-detail-table td {
    padding: .75mm .8mm;
    border: .2mm solid #d4d8dc;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.desktop-detail-table th {
    background: #e9edf1;
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
}

.desktop-detail-table td.number,
.desktop-detail-table th.number {
    text-align: right !important;
    white-space: nowrap;
}

.desktop-detail-table .desktop-liquid-cell {
    font-weight: 700;
}

.desktop-detail-table th:nth-child(1) { width: 5.0%; }
.desktop-detail-table th:nth-child(2) { width: 7.4%; }
.desktop-detail-table th:nth-child(3) { width: 6.1%; }
.desktop-detail-table th:nth-child(4) { width: 12.5%; }
.desktop-detail-table th:nth-child(5) { width: 8.3%; }
.desktop-detail-table th:nth-child(6) { width: 8.4%; }
.desktop-detail-table th:nth-child(7) { width: 8.8%; }
.desktop-detail-table th:nth-child(8) { width: 7.8%; }
.desktop-detail-table th:nth-child(9) { width: 7.8%; }
.desktop-detail-table th:nth-child(10),
.desktop-detail-table th:nth-child(11),
.desktop-detail-table th:nth-child(12),
.desktop-detail-table th:nth-child(13) { width: 6.45%; }

.desktop-total-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    margin-top: 2mm;
    border: .25mm solid #9b9b9b;
}

.desktop-total-strip > div {
    min-height: 10mm;
    padding: 1.1mm 1mm;
    text-align: center;
    border-right: .25mm solid #9b9b9b;
}

.desktop-total-strip > div:last-child {
    border-right: 0;
}

.desktop-total-strip span {
    display: block;
    font-size: 5.1pt;
    font-weight: 700;
}

.desktop-total-strip strong {
    display: block;
    margin-top: .8mm;
    font-size: 7.4pt;
    line-height: 1.05;
}

.desktop-print-warning {
    margin: 0 0 2mm;
    padding: 1.5mm;
    border: .25mm solid #c69b34;
    background: #fff9df;
    font-size: 5.8pt;
}

.desktop-report-footer {
    margin-top: 2.5mm;
    padding-top: 2mm;
    border-top: .2mm solid #bfbfbf;
    color: #666;
    text-align: center;
    font-size: 5.4pt;
    line-height: 1.2;
}

@media print {
    .desktop-report-sheet {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .desktop-report-landscape .desktop-company-header {
        min-height: 26mm;
    }

    .desktop-detail-table thead {
        display: table-header-group;
    }

    .desktop-detail-table tr {
        break-inside: avoid;
    }

    .desktop-total-strip,
    .desktop-report-footer {
        break-inside: avoid;
    }
}
