:root {
    --bg: #f3f6fb;
    --bg-strong: #e6edf6;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --surface-border: rgba(15, 23, 42, 0.08);
    --text: #122033;
    --muted: #607089;
    --primary: #0a66c2;
    --primary-strong: #084d93;
    --accent: #14b8a6;
    --success: #138a63;
    --danger: #c2410c;
    --shadow-soft: 0 18px 50px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 22px 60px rgba(15, 23, 42, 0.12);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --container: 1440px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.14), transparent 28%),
        radial-gradient(circle at top right, rgba(10, 102, 194, 0.18), transparent 32%),
        linear-gradient(180deg, #f9fbfd 0%, var(--bg) 55%, #edf2f9 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(18, 32, 51, 0.028) 1px, transparent 1px), linear-gradient(90deg, rgba(18, 32, 51, 0.028) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 75%);
}

img {
    display: block;
    max-width: 100%;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
}

.page-shell {
    width: min(calc(100% - 24px), var(--container));
    margin: 0 auto;
    padding: 18px 0 40px;
}

.hero {
    position: relative;
    overflow: hidden;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: calc(var(--radius-xl) + 4px);
    background:
        linear-gradient(135deg, rgba(9, 32, 60, 0.98), rgba(12, 62, 113, 0.92) 58%, rgba(20, 184, 166, 0.62) 140%),
        #09203c;
    box-shadow: var(--shadow-card);
    color: #f6fbff;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -120px -120px auto;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
}

.hero__eyebrow,
.detail-card__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero__content {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 18px;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    margin-top: 18px;
}

.hero h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.65rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.hero p {
    max-width: 700px;
    margin: 18px 0 0;
    color: rgba(246, 251, 255, 0.82);
    font-size: 1rem;
    line-height: 1.6;
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.hero__badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
}

.hero__badge {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.1);
    color: #f5fbff;
}

.dashboard {
    margin-top: 24px;
    display: grid;
    gap: 20px;
}

.search-card,
.panel,
.metric-card,
.feedback,
.empty-state {
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow-soft);
}

.search-card {
    padding: 18px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: end;
}

.field {
    display: grid;
    gap: 10px;
}

.field__control {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: nowrap;
}

.field__control--search {
    gap: 0;
}

.field__label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.field input,
.field select {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid rgba(96, 112, 137, 0.24);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field__control--search input {
    min-width: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.field input:focus,
.field select:focus {
    border-color: rgba(10, 102, 194, 0.65);
    box-shadow: 0 0 0 4px rgba(10, 102, 194, 0.12);
    transform: translateY(-1px);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 20px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.button__icon {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(10, 102, 194, 0.2);
}

.button--primary[disabled] {
    opacity: 0.7;
    cursor: wait;
}

.button--ghost {
    border: 1px solid rgba(96, 112, 137, 0.18);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
}

.button--whatsapp {
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(18, 140, 126, 0.18);
}

.button--scan {
    min-width: 56px;
    width: 56px;
    padding: 0;
    background: linear-gradient(135deg, #0f172a, #1e3a5f);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.button--scan + .button--scan {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.button--scan.is-active {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.search-card__footer {
    display: flex;
    gap: 16px;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(96, 112, 137, 0.12);
}

.search-card__footer strong,
.panel h2,
.empty-state h2 {
    font-size: 1rem;
}

.search-card__footer p,
.panel p,
.empty-state p,
.feedback p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.status-pill {
    white-space: nowrap;
}

.status-pill--success {
    background: rgba(19, 138, 99, 0.12);
    color: var(--success);
}

.status-pill--neutral {
    background: rgba(10, 102, 194, 0.1);
    color: var(--primary);
}

.feedback,
.empty-state {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 22px 24px;
}

.feedback--error {
    border-color: rgba(194, 65, 12, 0.18);
    background: rgba(255, 244, 237, 0.94);
}

.feedback strong {
    color: var(--danger);
}

.empty-state--hero {
    min-height: 180px;
}

.empty-state__icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(10, 102, 194, 0.14), rgba(20, 184, 166, 0.18));
    color: var(--primary-strong);
    font-size: 1.4rem;
    font-weight: 700;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 22px;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: auto -30px -45px auto;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(10, 102, 194, 0.1), transparent 70%);
}

.metric-card__label,
.metric-card__hint,
.panel__timestamp,
.market-cell span,
.product-cell span,
.detail-grid span,
.detail-list__item span,
.table-empty {
    color: var(--muted);
}

.metric-card__label,
.detail-grid span,
.detail-list__item span {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card__value {
    display: block;
    margin-top: 14px;
    font-size: clamp(1.5rem, 3vw, 2.3rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.metric-card__hint {
    display: block;
    margin-top: 10px;
    line-height: 1.5;
}

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

.panel {
    padding: 18px;
}

.panel--details {
    position: static;
}

.panel__header {
    display: flex;
    gap: 16px;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    margin-bottom: 18px;
}

.panel__header--stacked {
    margin-bottom: 20px;
}

.panel h2 {
    margin: 0;
    font-size: 1.15rem;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
}

.field--compact {
    min-width: 0;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(96, 112, 137, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
}

.results-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
}

.results-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 16px 18px;
    background: #eff4fb;
    color: #42516a;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.results-table tbody td {
    padding: 16px 18px;
    border-top: 1px solid rgba(96, 112, 137, 0.1);
    vertical-align: middle;
}

.result-row {
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.result-row:hover,
.result-row:focus-visible {
    outline: none;
    background: rgba(10, 102, 194, 0.05);
}

.result-row.is-selected {
    background: linear-gradient(90deg, rgba(10, 102, 194, 0.08), rgba(20, 184, 166, 0.04));
    box-shadow: inset 4px 0 0 var(--primary);
}

.product-cell,
.market-cell {
    display: flex;
    gap: 14px;
    align-items: center;
}

.product-cell {
    position: relative;
}

.product-cell strong,
.market-cell strong,
.detail-grid strong,
.detail-list__item strong {
    display: block;
}

.product-cell__media,
.detail-card__media {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(10, 102, 194, 0.08), rgba(20, 184, 166, 0.14));
}

.product-cell__media {
    width: 52px;
    height: 52px;
}

.product-cell__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-cell__media span,
.detail-card__media span {
    color: var(--primary-strong);
    font-weight: 700;
    font-size: 0.82rem;
}

.price-cell {
    font-weight: 800;
    color: var(--primary-strong);
}

.table-empty {
    padding: 20px;
    text-align: center;
}

.detail-card {
    display: grid;
    gap: 20px;
}

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

.detail-card__media {
    width: 96px;
    height: 96px;
    border: 1px solid rgba(96, 112, 137, 0.14);
}

.detail-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-card h3 {
    margin: 10px 0 8px;
    font-size: 1.5rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.detail-card p {
    margin: 0;
    color: var(--muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.detail-grid > div,
.detail-list__item {
    padding: 16px;
    border: 1px solid rgba(96, 112, 137, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.82);
}

.detail-grid strong {
    margin-top: 8px;
    font-size: 1.1rem;
}

.detail-list {
    display: grid;
    gap: 10px;
}

.detail-list__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.detail-list__item strong {
    text-align: left;
}

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.button--action-gtin,
.button--action-share,
.button--action-copy-barcode,
.button--action-copy-cnpj {
    width: 100%;
}

.button--action-gtin {
    background: linear-gradient(135deg, #0a66c2, #084d93);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(10, 102, 194, 0.18);
}

.button--action-share {
    background: linear-gradient(135deg, #14b8a6, #0f8f86);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(20, 184, 166, 0.18);
}

.button--action-copy-barcode {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(217, 119, 6, 0.18);
}

.button--action-copy-cnpj {
    background: linear-gradient(135deg, #334155, #0f172a);
    color: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
}

.table-empty-action {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.hover-product-card {
    position: fixed;
    z-index: 45;
    width: min(340px, calc(100vw - 24px));
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    pointer-events: none;
}

.hover-product-card__media {
    width: 88px;
    height: 88px;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(10, 102, 194, 0.08), rgba(20, 184, 166, 0.14));
}

.hover-product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hover-product-card__content {
    min-width: 0;
}

.hover-product-card__header strong,
.hover-product-card__grid strong {
    display: block;
}

.hover-product-card__header strong {
    font-size: 0.98rem;
    line-height: 1.3;
}

.hover-product-card__header span,
.hover-product-card__grid span {
    color: var(--muted);
}

.hover-product-card__header span {
    display: block;
    margin-top: 4px;
}

.hover-product-card__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 12px;
}

.hover-product-card__grid div {
    padding-top: 8px;
    border-top: 1px solid rgba(96, 112, 137, 0.12);
}

.hover-product-card__grid span {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.hover-product-card__grid strong {
    margin-top: 4px;
    font-size: 0.9rem;
    word-break: break-word;
}

.scanner-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
}

.scanner-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 16, 29, 0.62);
    backdrop-filter: blur(8px);
}

.scanner-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
    overflow: hidden;
}

.scanner-modal__header {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 24px 16px;
}

.scanner-modal__eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.scanner-modal__header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.scanner-modal__header p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.scanner-modal__content {
    padding: 0 24px 24px;
}

.scanner-modal__viewport {
    position: relative;
    overflow: hidden;
    border-radius: 22px;
    background: linear-gradient(135deg, #0f172a, #102541);
    aspect-ratio: 16 / 10;
}

.scanner-modal__viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-modal__frame {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(74%, 420px);
    height: 132px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.18);
}

.scanner-modal__frame::before {
    content: "";
    position: absolute;
    inset: 50% 16px auto 16px;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, #25d366, transparent);
    animation: scanner-line 1.8s linear infinite;
}

.scanner-modal__status {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(10, 102, 194, 0.08);
    color: var(--text);
    font-weight: 600;
}

@keyframes scanner-line {
    0% {
        opacity: 0.25;
        transform: translateY(-36px);
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.25;
        transform: translateY(36px);
    }
}

.is-hidden {
    display: none;
}

@media (max-width: 640px) {
    .hero {
        padding: 20px;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
    }

    .results-table,
    .results-table tbody,
    .results-table tr,
    .results-table td {
        display: block;
        width: 100%;
    }

    .results-table thead {
        display: none;
    }

    .results-table tbody {
        display: grid;
        gap: 12px;
    }

    .results-table tbody td {
        padding: 0;
        border-top: 0;
    }

    .result-row {
        display: grid;
        gap: 10px;
        padding: 14px;
        border: 1px solid rgba(96, 112, 137, 0.14);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    }

    .result-row td:not(:first-child) {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .result-row td:not(:first-child)::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .product-cell {
        gap: 12px;
        align-items: flex-start;
    }

    .product-cell > div:last-child {
        min-width: 0;
    }

    .product-cell strong {
        line-height: 1.35;
    }

    .hover-product-card {
        display: none;
    }
}

@media (min-width: 861px) {
    .page-shell {
        width: min(calc(100% - 40px), var(--container));
        padding-top: 32px;
    }

    .hero__content,
    .search-card__footer,
    .panel__header,
    .toolbar,
    .detail-actions {
        flex-direction: row;
        align-items: flex-start;
    }

    .search-form {
        grid-template-columns: minmax(0, 1fr) auto auto auto;
    }

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

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

    .field__control--search input,
    .button--scan {
        border-radius: 0;
    }

    .field__control--search input {
        border-top-left-radius: var(--radius-sm);
        border-bottom-left-radius: var(--radius-sm);
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .button--scan {
        border-radius: 0;
    }

    .button--scan:last-child {
        border-top-right-radius: var(--radius-sm);
        border-bottom-right-radius: var(--radius-sm);
    }

    .detail-list__item {
        flex-direction: row;
        align-items: center;
    }

    .detail-list__item strong {
        text-align: right;
    }

    .detail-actions {
        flex-direction: row;
    }

    .button--action-gtin,
    .button--action-share,
    .button--action-copy-barcode,
    .button--action-copy-cnpj {
        width: auto;
    }

    .results-table {
        min-width: 640px;
    }
}

@media (min-width: 1181px) {
    .hero__content {
        gap: 24px;
        align-items: flex-end;
    }

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

    .workspace-grid {
        grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
    }

    .panel--details {
        position: sticky;
        top: 16px;
    }

    .panel__header {
        justify-content: space-between;
    }

    .toolbar {
        align-items: end;
    }

    .field--compact {
        min-width: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
