* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #111827;
    background: #f6f7f9;
}

a { color: inherit; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes status-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.6); opacity: .38; }
}

@keyframes progress-shine {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.topbar {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 5vw, 72px);
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 800;
    letter-spacing: .04em;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: white;
    font-weight: 900;
}

.brand small {
    display: block;
    color: #6b7280;
    font-weight: 600;
    letter-spacing: .14em;
    margin-top: 2px;
}

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #4b5563;
    font-size: 14px;
}

.button-link {
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    background: #fff;
}

main { padding: 34px clamp(18px, 5vw, 72px) 52px; }

.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

h1 {
    font-size: clamp(30px, 4vw, 54px);
    line-height: 1;
    margin: 0 0 18px;
    padding: clamp(20px, 4vw, 32px);
    border: 2px var(--primary) dotted;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary), transparent 95%);
    color: var(--secondary);
    letter-spacing: 0;
}

.lead {
    max-width: 760px;
    color: #5b6472;
    font-size: 17px;
    line-height: 1.55;
    margin: 0 0 26px;
}

.panel,
.card {
    background: #fff;
    border: 1px solid #e6e8ee;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(17, 24, 39, .06);
}

.search-panel {
    padding: clamp(18px, 3vw, 28px);
    border-color: color-mix(in srgb, var(--primary), white 78%);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary), white 94%), #fff 42%),
        #fff;
}

.search-card-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.search-card-head > div {
    display: grid;
    gap: 4px;
}

.search-card-head strong {
    color: var(--secondary);
    font-size: 21px;
    letter-spacing: 0;
}

.search-eyebrow {
    color: color-mix(in srgb, var(--primary), #111827 28%);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.search-chip {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid color-mix(in srgb, var(--primary), white 72%);
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary), white 90%);
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.search-composer {
    display: grid;
    grid-template-columns: minmax(170px, 230px) 1fr;
    gap: 18px;
    align-items: start;
}

.search-type-menu {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.search-type-menu legend {
    margin-bottom: 4px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.search-type-option {
    min-height: 58px;
    display: grid;
    grid-template-columns: 38px 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: rgba(255, 255, 255, .82);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.search-type-option:hover {
    border-color: color-mix(in srgb, var(--primary), white 62%);
    transform: translateX(2px);
}

.search-type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.search-type-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 12px;
    font-weight: 900;
}

.search-type-option strong {
    display: block;
    color: #111827;
    font-size: 14px;
}

.search-type-option small {
    display: block;
    margin-top: 2px;
    color: #6b7280;
    font-size: 12px;
}

.search-type-option:has(input:checked) {
    border-color: color-mix(in srgb, var(--primary), white 50%);
    background: color-mix(in srgb, var(--primary), white 92%);
    box-shadow: inset 4px 0 0 var(--primary), 0 12px 24px rgba(17, 24, 39, .06);
}

.search-type-option:has(input:checked) .search-type-icon {
    background: var(--primary);
    color: #fff;
}

.search-type-option:has(input:checked) strong {
    color: var(--primary);
}

.search-fields {
    display: grid;
    width: min(100%, 760px);
    grid-template-columns: 1fr;
    gap: 16px;
    align-content: start;
    align-items: stretch;
    padding: 40px;
    border: 1px solid #e7eaf0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .82);
}

.search-composer.with-document .search-fields {
    grid-template-columns: 1fr;
}

.search-field {
    display: grid;
    gap: 8px;
}

.search-field span {
    color: #6b7280;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

select,
input {
    width: 100%;
    height: 52px;
    border: 1px solid #d9dde6;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 15px;
    background: #fff;
    color: #111827;
}

input[type="radio"] {
    width: auto;
    height: auto;
    padding: 0;
}

.search-panel.was-validated input:invalid {
    border-color: #dc2626;
    background: #fff7f7;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.search-panel.was-validated input:invalid:focus {
    outline: 0;
    border-color: #b91c1c;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, .18);
}

button {
    height: 52px;
    border: 0;
    border-radius: 8px;
    padding: 0 24px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.search-fields button {
    width: 100%;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px color-mix(in srgb, var(--primary), transparent 72%);
}

button:disabled {
    cursor: wait;
    opacity: .82;
    transform: none;
}

.helper {
    margin-top: 12px;
    font-size: 13px;
    color: #6b7280;
}

.form-status {
    display: none;
    position: relative;
    margin-top: 14px;
    height: 4px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef1f6;
}

.form-status::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 60%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: progress-shine 1.1s ease-in-out infinite;
}

.search-panel.is-loading .form-status { display: block; }

.aside {
    padding: 22px;
    display: grid;
    gap: 14px;
}

.aside-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.aside-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #fff1f2;
    color: var(--primary);
    font-weight: 900;
}

.results {
    margin-top: 28px;
    display: grid;
    gap: 18px;
    scroll-margin-top: 94px;
}

.results.has-feedback {
    animation: fade-up .28s ease both;
}

.result-list {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 2px solid color-mix(in srgb, var(--primary), white 58%);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--primary), transparent 88%);
}

.result-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: end;
    margin: -6px -6px 8px;
    padding: 14px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--primary), white 93%);
}

.result-head h2 {
    color: var(--secondary);
}

.result-row {
    display: grid;
    grid-template-columns: minmax(170px, .75fr) minmax(220px, 1fr) minmax(160px, .7fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border: 1px solid #e7eaf0;
    border-radius: 8px;
    background: linear-gradient(135deg, #fff, color-mix(in srgb, var(--status), white 96%));
    animation: fade-up .34s ease both;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.result-row:hover {
    border-color: color-mix(in srgb, var(--primary), white 66%);
    box-shadow: 0 18px 34px rgba(17, 24, 39, .08);
    transform: translateY(-1px);
}

.route-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.route-arrow {
    color: var(--primary);
    font-weight: 900;
}

.detail-link {
    display: inline-flex;
    height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border-radius: 8px;
    background: var(--secondary);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.ghost-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    text-decoration: none;
    font-weight: 800;
}

.summary {
    padding: 22px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: start;
}

.results.has-feedback > .summary {
    border: 2px solid color-mix(in srgb, var(--status), white 58%);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--status), transparent 88%);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--status), white 84%);
    color: var(--status);
    font-weight: 800;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
    position: relative;
}

.pulse-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    animation: status-pulse 1.5s ease-in-out infinite;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.label {
    color: #6b7280;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.value {
    margin-top: 4px;
    font-weight: 750;
    color: #111827;
}

.timeline {
    padding: 22px;
}

.timeline-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
    margin-bottom: 24px;
}

.timeline-head h2 {
    margin: 4px 0 0;
    font-size: 24px;
    color: var(--secondary);
    letter-spacing: 0;
}

.timeline-count {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.timeline-rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0;
    align-items: start;
}

.timeline-step {
    position: relative;
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 0 12px;
    text-align: center;
    animation: fade-up .32s ease both;
}

.timeline-step::before,
.timeline-step::after {
    content: "";
    position: absolute;
    top: 30px;
    height: 4px;
    background: #d1d5db;
    z-index: 0;
}

.timeline-step::before {
    left: 0;
    right: 50%;
}

.timeline-step::after {
    left: 50%;
    right: 0;
}

.timeline-step:first-child::before,
.timeline-step:last-child::after {
    display: none;
}

.timeline-step.done::before,
.timeline-step.done::after,
.timeline-step.current::before {
    background: var(--step);
}

.timeline-step.current::after,
.timeline-step.pending::before,
.timeline-step.pending::after {
    background: #d1d5db;
}

.timeline-marker {
    position: relative;
    z-index: 1;
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 2px solid var(--step);
    background: var(--step);
    color: #fff;
    box-shadow: 0 16px 34px color-mix(in srgb, var(--step), transparent 70%);
}

.timeline-marker svg {
    width: 31px;
    height: 31px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.timeline-step.current .timeline-marker {
    outline: 6px solid color-mix(in srgb, var(--step), white 78%);
}

.timeline-step.pending .timeline-marker {
    border-color: #d1d5db;
    background: #fff;
    color: #b7bdc8;
    box-shadow: none;
}

.timeline-copy {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 4px;
}

.timeline-copy span {
    color: #6b7280;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.timeline-copy strong {
    color: #111827;
    font-size: 15px;
}

.timeline-copy small {
    color: #6b7280;
    line-height: 1.35;
}

.timeline-step.done .timeline-copy span,
.timeline-step.current .timeline-copy span {
    color: var(--step);
}

.timeline-step.pending .timeline-copy strong,
.timeline-step.pending .timeline-copy small {
    color: #9ca3af;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.card { padding: 20px; }

.card h2 {
    font-size: 17px;
    margin: 0 0 14px;
}

.line {
    padding: 9px 0;
    border-top: 1px solid #eef0f4;
}

.line:first-of-type { border-top: 0; }

.docs,
.occurrences { grid-column: 1 / -1; }

.doc-row,
.occurrence-row {
    display: grid;
    grid-template-columns: 130px 1fr 120px 120px;
    gap: 14px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid #eef0f4;
}

.occurrence-row { grid-template-columns: 170px 1fr 120px; }

.muted { color: #6b7280; }

.empty {
    padding: 24px;
    border: 2px solid color-mix(in srgb, var(--primary), white 70%);
    border-radius: 8px;
    color: #374151;
    background: color-mix(in srgb, var(--primary), white 95%);
    box-shadow: 0 18px 46px rgba(17, 24, 39, .06);
    font-weight: 800;
}

.delivery-photo {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-top: 12px;
}

footer {
    padding: 24px;
    text-align: center;
    color: #7b8493;
    font-size: 13px;
}

@media (max-width: 900px) {
    .hero,
    .content-grid { grid-template-columns: 1fr; }

    .search-composer,
    .search-composer.with-document .search-fields,
    .summary,
    .summary-grid,
    .result-row,
    .doc-row,
    .occurrence-row { grid-template-columns: 1fr; }

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

    .search-type-menu legend {
        grid-column: 1 / -1;
    }

    .search-type-option {
        min-height: 54px;
    }

    .timeline-head {
        align-items: start;
        flex-direction: column;
    }

    .timeline-rail {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .timeline-step {
        grid-template-columns: 60px 1fr;
        justify-items: start;
        gap: 14px;
        padding: 0;
        text-align: left;
    }

    .timeline-step::before,
    .timeline-step::after {
        left: 30px;
        right: auto;
        width: 4px;
        height: calc(50% + 10px);
    }

    .timeline-step::before {
        top: -16px;
    }

    .timeline-step::after {
        top: 56px;
    }

    .timeline-marker {
        width: 60px;
        height: 60px;
    }

    .topbar {
        height: auto;
        padding-top: 14px;
        padding-bottom: 14px;
        align-items: flex-start;
        gap: 12px;
    }

    .result-head {
        align-items: start;
        flex-direction: column;
    }
}
