:root {
    --green-900: #173c25;
    --green-800: #244f30;
    --green-700: #315f3b;
    --green-100: #e8f0e9;
    --orange: #ef7d00;
    --orange-soft: #fff1df;
    --gray-900: #1d2821;
    --gray-700: #526057;
    --gray-500: #879189;
    --gray-300: #d7ded8;
    --gray-100: #f3f6f3;
    --white: #fff;
    --danger: #a93832;
    --shadow: 0 14px 40px rgba(26, 59, 34, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
    margin: 0;
    color: var(--gray-900);
    background: #f4f6f2;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    line-height: 1.5;
}
button, input { font: inherit; }
button { cursor: pointer; }
.container { width: min(1160px, calc(100% - 32px)); margin-inline: auto; }
.site-header {
    color: var(--white);
    background: linear-gradient(120deg, var(--green-900), var(--green-700));
    box-shadow: 0 3px 14px rgba(17, 53, 29, .18);
}
.header-content {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
}
.brand picture {
    width: 154px;
    height: 52px;
    display: block;
    overflow: hidden;
    border-radius: 9px;
    background: var(--white);
}
.brand img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.portal-nav { display: flex; gap: 22px; }
.portal-nav a { color: rgba(255,255,255,.86); font-size: .86rem; font-weight: 650; text-decoration: none; }
.portal-nav a:hover { color: var(--white); }
.page-content { min-height: calc(100vh - 148px); padding-block: 36px 56px; }
.search-panel {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(350px, .78fr);
    align-items: end;
    gap: 48px;
    padding: 34px 38px;
    border: 1px solid rgba(49, 95, 59, .1);
    border-radius: 18px;
    background: var(--white);
    box-shadow: var(--shadow);
}
.eyebrow, .section-kicker {
    margin: 0 0 6px;
    color: var(--orange);
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--green-900); font-size: clamp(1.8rem, 3vw, 2.65rem); line-height: 1.12; }
h2 { margin-bottom: 0; color: var(--green-900); font-size: 1.35rem; }
.subtitle { margin-bottom: 0; color: var(--gray-700); }
.search-form label { display: block; margin-bottom: 8px; color: var(--green-900); font-size: .86rem; font-weight: 700; }
.search-controls { display: flex; gap: 10px; }
.search-controls input {
    min-width: 0;
    flex: 1;
    padding: 13px 15px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    outline: none;
}
.search-controls input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(239,125,0,.14); }
.search-controls button, .secondary-button {
    padding: 12px 18px;
    border: 0;
    border-radius: 9px;
    color: var(--white);
    background: var(--orange);
    font-weight: 750;
}
.search-controls button:hover { background: #d96f00; }
.feedback, .loading-card {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 11px;
}
.feedback { border: 1px solid #e7b8b4; color: var(--danger); background: #fff1f0; }
.loading-card { display: flex; align-items: center; gap: 12px; color: var(--green-800); background: var(--white); box-shadow: var(--shadow); }
.spinner { width: 19px; height: 19px; border: 3px solid var(--green-100); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#resultado { display: grid; gap: 20px; margin-top: 24px; }
.summary-card, .content-card {
    padding: 28px;
    border: 1px solid rgba(49, 95, 59, .1);
    border-radius: 16px;
    background: var(--white);
    box-shadow: 0 8px 25px rgba(26,59,34,.055);
}
.summary-card { border-top: 4px solid var(--orange); }
.summary-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.status-badge { padding: 8px 13px; border-radius: 999px; color: #8a4700; background: var(--orange-soft); font-size: .84rem; font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.info-block { min-width: 0; padding: 14px; border-radius: 10px; background: var(--gray-100); }
.info-block span { display: block; margin-bottom: 3px; color: var(--gray-700); font-size: .73rem; font-weight: 700; text-transform: uppercase; }
.info-block strong { display: block; overflow-wrap: anywhere; color: var(--green-900); }
.secondary-button { margin-top: 18px; color: var(--green-800); background: var(--green-100); }
.document-dialog {
    width: min(470px, calc(100% - 28px));
    padding: 0;
    border: 0;
    border-radius: 16px;
    color: var(--gray-900);
    background: var(--white);
    box-shadow: 0 24px 80px rgba(12, 37, 21, .28);
}
.document-dialog::backdrop { background: rgba(14, 35, 22, .62); backdrop-filter: blur(2px); }
.document-dialog form { padding: 27px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.dialog-description { margin: 10px 0 20px; color: var(--gray-700); }
.document-dialog label { display: block; margin-bottom: 7px; color: var(--green-900); font-size: .84rem; font-weight: 750; }
.document-dialog input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    outline: none;
}
.document-dialog input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(239,125,0,.14); }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--gray-700); background: var(--gray-100); font-size: 1.35rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.cancel-button, .primary-button { padding: 11px 17px; border-radius: 9px; font-weight: 750; }
.cancel-button { border: 1px solid var(--gray-300); color: var(--green-800); background: var(--white); }
.primary-button { border: 0; color: var(--white); background: var(--orange); }
.field-feedback { margin: 9px 0 0; color: var(--danger); font-size: .84rem; }
.status-legend { display: flex; align-items: center; gap: 7px; color: var(--gray-700); font-size: .8rem; }
.status-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.status-track { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 12px 0 0; padding: 0; list-style: none; }
.status-track::before { content: ""; position: absolute; top: 18px; left: 10%; right: 10%; height: 3px; background: var(--gray-300); }
.status-step { position: relative; z-index: 1; text-align: center; }
.status-dot { width: 38px; height: 38px; display: grid; place-items: center; margin: 0 auto 10px; border: 3px solid var(--gray-300); border-radius: 50%; color: var(--gray-500); background: var(--white); font-size: .85rem; font-weight: 800; }
.status-step strong { display: block; padding-inline: 6px; color: var(--gray-500); font-size: .82rem; }
.status-step.concluido .status-dot { border-color: var(--green-700); color: var(--white); background: var(--green-700); }
.status-step.concluido strong { color: var(--green-700); }
.status-step.atual .status-dot { transform: scale(1.14); border-color: var(--orange); color: var(--white); background: var(--orange); box-shadow: 0 0 0 6px var(--orange-soft); }
.status-step.atual strong { color: #a75500; }
.status-step small { display: block; margin-top: 4px; color: var(--orange); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.details-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 20px; }
.compact-list { display: grid; gap: 10px; }
.compact-item { display: flex; justify-content: space-between; gap: 20px; padding: 13px 14px; border-radius: 9px; background: var(--gray-100); }
.compact-item span { color: var(--gray-700); font-size: .82rem; }
.note-link { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: var(--green-800); background: transparent; font: inherit; font-weight: 800; text-decoration: underline; text-decoration-color: var(--orange); text-underline-offset: 3px; cursor: pointer; }
.note-link:hover, .note-link:focus-visible { color: var(--orange); }
.note-download-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.products-list { display: grid; gap: 16px; }
.product-card { overflow: hidden; border: 1px solid var(--gray-300); border-radius: 12px; }
.product-header { display: flex; justify-content: space-between; gap: 20px; padding: 18px; background: var(--gray-100); }
.product-header h3 { margin: 3px 0 0; color: var(--green-900); font-size: 1rem; }
.product-code { color: var(--orange); font-size: .75rem; font-weight: 800; }
.quantity { white-space: nowrap; color: var(--green-800); font-weight: 800; }
.treatment { margin: 0; padding: 11px 18px; color: #725000; background: #fff8dc; font-size: .86rem; }
.lots { display: grid; }
.lot-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 14px 18px; border-top: 1px solid var(--gray-300); }
.lot-row:first-child { border-top: 0; }
.lot-identification { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lot-identification span { color: var(--green-700); font-size: .76rem; font-weight: 800; }
.lot-link { color: var(--green-700); font-size: .84rem; font-weight: 800; text-decoration: none; }
.lot-link:hover { color: var(--orange); }
.empty-state { margin: 0; color: var(--gray-700); font-size: .9rem; }
.route-layout { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(420px, 1.6fr); gap: 18px; }
.route-summary { display: grid; align-content: start; gap: 12px; }
.route-place, .route-origins { padding: 14px; border-radius: 10px; background: var(--gray-100); }
.route-place span, .route-origins > span { display: block; margin-bottom: 4px; color: var(--orange); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.route-place strong { color: var(--green-900); }
.route-place p, .route-origins p { margin: 5px 0 0; color: var(--gray-700); font-size: .85rem; line-height: 1.4; }
.route-place small { display: block; margin-top: 8px; color: var(--gray-700); line-height: 1.35; }
.route-link { justify-self: start; padding: 10px 14px; border-radius: 9px; color: var(--white); background: var(--green-700); font-weight: 750; text-decoration: none; }
.route-map-wrap { min-width: 0; }
.route-map { width: 100%; min-height: 390px; display: block; border: 0; border-radius: 12px; background: var(--gray-100); }
.route-note { margin: 8px 0 0; color: var(--gray-700); font-size: .78rem; }
.site-footer { padding: 18px 0; color: var(--gray-500); background: #e9ede8; font-size: .78rem; text-align: center; }
.lot-section, .lot-detail { margin-top: 20px; }
.lot-detail { display: grid; gap: 20px; }
.lot-product-name { margin: -9px 0 22px; color: var(--gray-700); font-size: 1.03rem; }
.origin-grid { gap: 8px; }
.origin-grid .info-block { padding: 9px 11px; }
.origin-grid .info-block span { margin-bottom: 1px; font-size: .68rem; }
.origin-grid .info-block strong { font-size: .9rem; line-height: 1.25; }
.selection-list { display: grid; gap: 10px; }
.selection-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 16px; border: 1px solid var(--gray-300); border-radius: 10px; color: var(--gray-900); text-decoration: none; }
.selection-item:hover { border-color: var(--orange); background: var(--orange-soft); }
.selection-item span { display: grid; gap: 3px; }
.selection-item strong { color: var(--green-800); }
.selection-item b { white-space: nowrap; color: var(--orange); font-size: .84rem; }
.laboratory-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; }
.laboratory-card { padding: 18px 14px; border-radius: 11px; text-align: center; background: var(--green-100); }
.laboratory-card span { display: block; margin-bottom: 6px; color: var(--green-700); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.laboratory-card strong { color: var(--green-900); font-size: 1.45rem; }
.lot-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gallery-button { position: relative; aspect-ratio: 1; overflow: hidden; padding: 0; border: 0; border-radius: 11px; background: var(--gray-100); }
.lot-gallery img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .2s ease; }
.gallery-button:hover img { transform: scale(1.035); }
.gallery-button span { position: absolute; inset: auto 8px 8px; padding: 6px 8px; border-radius: 7px; color: var(--white); background: rgba(18, 50, 29, .82); font-size: .74rem; font-weight: 700; }
.document-list { display: grid; gap: 10px; }
.document-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 16px; border: 1px solid var(--gray-300); border-radius: 10px; color: var(--gray-900); background: var(--white); text-align: left; }
.document-item:hover { border-color: var(--orange); background: var(--orange-soft); }
.document-item span { display: grid; gap: 2px; }
.document-item small { color: var(--gray-700); }
.document-item b { white-space: nowrap; color: var(--green-700); font-size: .84rem; }
.file-alerts { margin-top: 14px; padding: 12px 14px; border-radius: 9px; color: #805000; background: #fff4cf; font-size: .86rem; }
.auth-card { width: min(480px, 100%); margin: 26px auto; padding: 32px; border-radius: 16px; background: var(--white); box-shadow: var(--shadow); }
.lab-form { display: grid; gap: 8px; margin-top: 24px; }
.lab-form label { margin-top: 7px; color: var(--green-900); font-size: .84rem; font-weight: 750; }
.lab-form input { width: 100%; padding: 12px 13px; border: 1px solid var(--gray-300); border-radius: 9px; outline: none; }
.lab-form input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(239,125,0,.14); }
.lab-form .primary-button { margin-top: 12px; }
.lab-heading { align-items: center; }
.lab-heading .secondary-button { justify-self: end; margin-top: 0; }
.lab-sync-card { margin-top: 20px; }
.lab-sync-card > p { color: var(--gray-700); }
.sync-result { display: grid; gap: 3px; margin-top: 16px; padding: 14px; border-radius: 9px; color: var(--green-800); background: var(--green-100); }
.sync-result.error { color: var(--danger); background: #fff1f0; }
.lab-files-card { margin-top: 20px; }
.lab-files-card > p { color: var(--gray-700); }
.lab-upload-form { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; align-items: end; }
.lab-field { display: grid; gap: 7px; }
.lab-field label { color: var(--green-900); font-size: .8rem; font-weight: 750; }
.lab-field input, .lab-field select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 9px; color: var(--gray-900); background: var(--white); outline: none; }
.lab-field input:focus, .lab-field select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(239,125,0,.14); }
.lab-upload-actions { grid-column: 1 / -1; display: flex; gap: 10px; }
.lab-upload-actions .secondary-button { margin-top: 0; }
.lab-file-list { display: grid; gap: 9px; margin-top: 18px; }
.lab-file-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 14px; border: 1px solid var(--gray-300); border-radius: 10px; }
.lab-file-item > div:first-child { min-width: 0; display: grid; gap: 3px; }
.lab-file-item span { overflow-wrap: anywhere; color: var(--gray-700); font-size: .82rem; }
.lab-file-actions { display: flex; align-items: center; gap: 8px; }
.lab-file-actions .secondary-button { display: inline-block; margin: 0; padding: 9px 12px; text-decoration: none; }
.archive-button { padding: 9px 12px; border: 1px solid #e6aaa5; border-radius: 9px; color: #9e2d24; background: #fff4f3; font-weight: 750; }
.file-viewer { width: min(1100px, calc(100% - 28px)); height: min(820px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 16px; color: var(--gray-900); background: var(--white); box-shadow: 0 28px 90px rgba(6, 27, 14, .38); }
.file-viewer::backdrop { background: rgba(8, 28, 16, .78); backdrop-filter: blur(3px); }
.file-viewer-header, .file-viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; }
.file-viewer-header { border-bottom: 1px solid var(--gray-300); }
.file-viewer-header h2 { max-width: 75vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-viewer-footer { border-top: 1px solid var(--gray-300); color: var(--gray-700); font-size: .84rem; }
.file-viewer-stage { position: relative; height: calc(100% - 145px); overflow: hidden; background: #18221b; }
.image-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }
.image-canvas { min-width: 100%; min-height: 100%; display: flex; align-items: center; justify-content: center; }
.file-viewer-stage img { display: block; max-width: none; max-height: none; object-fit: contain; }
.file-viewer-stage iframe { width: 100%; height: 100%; border: 0; background: var(--white); }
.danfe-loading { height: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--white); }
.danfe-feedback { width: min(520px, calc(100% - 32px)); margin: 40px auto; padding: 16px; border-radius: 10px; color: #8f251d; background: #fff1f0; text-align: center; }
.viewer-nav { position: absolute; z-index: 2; top: 50%; width: 46px; height: 58px; transform: translateY(-50%); border: 0; border-radius: 10px; color: var(--white); background: rgba(17, 52, 29, .72); font-size: 2rem; }
.viewer-nav:hover { background: var(--orange); }
.viewer-prev { left: 14px; }
.viewer-next { right: 14px; }
.zoom-controls { display: flex; align-items: center; justify-content: center; gap: 7px; }
.zoom-controls button { min-width: 36px; height: 34px; padding: 0 10px; border: 1px solid var(--gray-300); border-radius: 8px; color: var(--green-800); background: var(--white); font-weight: 750; }
.zoom-controls button:hover { border-color: var(--orange); color: var(--orange); }
.zoom-controls span { min-width: 48px; text-align: center; font-weight: 700; }
[hidden] { display: none !important; }

@media (max-width: 850px) {
    .search-panel { grid-template-columns: 1fr; gap: 24px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .route-layout { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
    .container { width: min(100% - 22px, 1160px); }
    .header-content { min-height: 66px; }
    .brand picture {
        width: 48px;
        height: 48px;
        border-radius: 50%;
    }
    .brand img { object-fit: contain; }
    .portal-nav { gap: 12px; }
    .portal-nav a:first-child { display: none; }
    .portal-nav a { font-size: .76rem; }
    .page-content { padding-block: 18px 38px; }
    .search-panel, .summary-card, .content-card { padding: 21px 18px; border-radius: 13px; }
    .search-controls { flex-direction: column; }
    .search-controls button { width: 100%; }
    .summary-grid, .details-grid { grid-template-columns: 1fr; }
    .route-map { min-height: 310px; }
    .summary-heading, .section-heading { align-items: flex-start; }
    .status-track { display: grid; grid-template-columns: 1fr; gap: 0; }
    .status-track::before { top: 18px; bottom: 18px; left: 18px; right: auto; width: 3px; height: auto; }
    .status-step { min-height: 66px; display: grid; grid-template-columns: 42px 1fr; align-items: start; text-align: left; }
    .status-dot { margin: 0; }
    .status-step strong { padding: 9px 0 0 12px; }
    .status-step small { grid-column: 2; margin: -17px 0 0 12px; }
    .product-header { flex-direction: column; gap: 8px; }
    .lot-row { grid-template-columns: 1fr auto; }
    .lot-link { grid-column: 1 / -1; }
    .dialog-actions { flex-direction: column-reverse; }
    .dialog-actions button { width: 100%; }
    .laboratory-grid { grid-template-columns: repeat(2, 1fr); }
    .lot-gallery { grid-template-columns: repeat(2, 1fr); }
    .document-item { align-items: flex-start; flex-direction: column; }
    .lab-upload-form { grid-template-columns: 1fr; }
    .lab-upload-actions { grid-column: 1; flex-direction: column; }
    .lab-upload-actions button { width: 100%; }
    .lab-file-item { align-items: flex-start; flex-direction: column; }
    .lab-file-actions { width: 100%; }
    .file-viewer { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; }
    .file-viewer-stage { height: calc(100% - 145px); }
    .viewer-nav { width: 42px; height: 52px; }
    .file-viewer-footer { gap: 8px; padding-inline: 10px; }
    .zoom-controls { gap: 4px; }
    .zoom-controls button { min-width: 32px; padding-inline: 7px; }
    #zoom-ajustar { display: none; }
}
