.product-history-kicker,
.product-history-stat-label {
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.product-history-controls {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.product-history-controls-head,
.product-history-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.product-history-controls-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.product-history-controls-head h2 {
    margin: 3px 0 0;
    font-size: 1rem;
    letter-spacing: 0;
}

.product-history-periods {
    display: inline-grid;
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.product-history-period {
    display: grid;
    place-items: center;
    min-height: 34px;
    padding: 0 10px;
    border-right: 1px solid var(--border);
    color: var(--text-3);
    font-size: 0.76rem;
    font-weight: 700;
}

.product-history-period:last-child {
    border-right: 0;
}

.product-history-period:hover,
.product-history-period.is-active {
    background: var(--accent);
    color: #111;
}

.product-history-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 12px;
    padding: 16px 18px;
}

.product-history-filter-grid label > span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-3);
    font-size: 0.72rem;
    font-weight: 600;
}

.product-history-filter-actions {
    display: flex;
    grid-column: 1 / -1;
    flex-wrap: wrap;
    gap: 8px;
}

.product-history-target-presets {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    grid-column: 1 / -1;
}

.product-history-target-presets > span {
    color: var(--text-3);
    font-size: 0.72rem;
    font-weight: 600;
}

.product-history-decision {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 230px);
    gap: 20px;
    margin-bottom: 14px;
    padding: 20px;
    border: 1px solid var(--border-2);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--surface-2);
}

.product-history-decision.is-good {
    border-left-color: var(--green);
}

.product-history-decision.is-warn {
    border-left-color: var(--yellow);
}

.product-history-target {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
    margin-bottom: 14px;
    padding: 18px 20px;
}

.product-history-target.is-reached {
    border-left-color: var(--green);
}

.product-history-target.is-near {
    border-left-color: var(--yellow);
}

.product-history-target h2 {
    font-size: 1.05rem;
    letter-spacing: 0;
    margin: 4px 0 6px;
}

.product-history-target p {
    color: var(--text-3);
    font-size: 0.8rem;
    margin: 0;
}

.product-history-target-metrics {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.product-history-target-metrics > div {
    border-left: 1px solid var(--border);
    display: grid;
    gap: 3px;
    min-width: 0;
    padding-left: 12px;
}

.product-history-target-metrics span,
.product-history-target-metrics small {
    color: var(--text-3);
    font-size: 0.68rem;
}

.product-history-target-metrics strong {
    overflow-wrap: anywhere;
}

.product-history-decision-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 3px;
}

.product-history-decision-title h2 {
    margin: 0;
    font-size: 1.18rem;
    letter-spacing: 0;
}

.product-history-decision-main p {
    max-width: 720px;
    margin: 8px 0 12px;
    color: var(--text-3);
    font-size: 0.82rem;
}

.product-history-decision-price {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-direction: column;
    min-width: 0;
    padding-left: 18px;
    border-left: 1px solid var(--border);
    text-align: right;
}

.product-history-decision-price span,
.product-history-decision-price small,
.product-history-insight span,
.product-history-insight small {
    color: var(--text-3);
    font-size: 0.7rem;
}

.product-history-decision-price strong {
    margin: 3px 0;
    color: var(--accent);
    font-size: 1.65rem;
    line-height: 1.1;
}

.product-history-insight-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.product-history-insight {
    min-width: 0;
    padding: 13px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.product-history-insight:nth-child(4n) {
    border-right: 0;
}

.product-history-insight:nth-last-child(-n + 4) {
    border-bottom: 0;
}

.product-history-insight span,
.product-history-insight strong,
.product-history-insight small {
    display: block;
}

.product-history-insight strong {
    margin: 4px 0 2px;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 0.94rem;
}

.product-history-chart-card .price-chart {
    height: auto;
    min-height: 180px;
}

.product-history-chart-card .price-chart > svg {
    display: block;
    width: 100%;
    min-height: 180px;
}

.product-history-small {
    margin-top: 3px;
    font-size: 0.68rem;
}

.product-history-section-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: flex-end;
}

.product-history-density {
    display: inline-flex;
}

.product-history-density .btn {
    border-radius: 0;
    margin-left: -1px;
}

.product-history-density .btn:first-child {
    border-radius: 6px 0 0 6px;
    margin-left: 0;
}

.product-history-density .btn:last-child {
    border-radius: 0 6px 6px 0;
}

.product-history-density .btn[aria-pressed="true"] {
    background: var(--accent);
    color: #111;
}

.product-history-data-table {
    overflow-x: auto;
}

.product-history-offers-table table {
    min-width: 1080px;
}

.product-history-offers-table tr.is-best {
    box-shadow: inset 3px 0 0 var(--green);
}

[data-product-history-workbench].is-compact .product-history-data-table td,
[data-product-history-workbench].is-compact .product-history-data-table th {
    padding-bottom: 0.45rem;
    padding-top: 0.45rem;
}

[data-product-history-workbench].is-compact .product-history-small {
    margin-top: 1px;
}

.product-history-stat-muted {
    color: var(--text-3);
}

.product-history-stat-positive,
.product-history-delta-down {
    color: var(--green);
}

.product-history-delta-up {
    color: var(--red);
}

.product-history-shop-list {
    display: grid;
    gap: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.product-history-summary-row {
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.product-history-summary-row:last-child {
    border-bottom: 0;
}

.product-history-shop-chips {
    margin-top: 7px;
}

.product-history-range {
    display: block;
    width: 100%;
    height: 12px;
    overflow: visible;
}

.product-history-range-bg {
    fill: rgba(232, 160, 48, 0.12);
}

.product-history-range-band {
    fill: rgba(232, 160, 48, 0.3);
}

.product-history-range-marker {
    fill: var(--accent);
    stroke: var(--accent-dim);
    stroke-width: 3;
    vector-effect: non-scaling-stroke;
}

.product-history-range-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.product-history-timeline-toolbar {
    padding-top: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.product-history-timeline-toolbar .result-control {
    max-width: 520px;
}

.product-history-timeline-table {
    max-height: 620px;
    overflow: auto;
}

.product-history-timeline-count {
    display: grid;
    gap: 3px;
    justify-items: end;
}

.product-history-timeline-count small {
    color: var(--text-3);
    font-size: 0.68rem;
}

.product-history-timeline-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
}

.product-history-date-cell {
    font-weight: 600;
    white-space: nowrap;
}

[data-history-empty][hidden] {
    display: none;
}

.product-history-sr-only {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 980px) {
    .product-history-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .product-history-insight:nth-child(odd) {
        border-right: 1px solid var(--border);
    }

    .product-history-insight:nth-child(even) {
        border-right: 0;
    }

    .product-history-insight:nth-last-child(-n + 4) {
        border-bottom: 1px solid var(--border);
    }

    .product-history-insight:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .product-history-target {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 860px) {
    .product-history-data-table {
        overflow: visible;
    }

    .product-history-data-table table,
    .product-history-data-table tbody,
    .product-history-data-table tr,
    .product-history-data-table td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .product-history-data-table thead {
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        height: 1px;
        overflow: hidden;
        position: absolute;
        white-space: nowrap;
        width: 1px;
    }

    .product-history-data-table tr {
        border-bottom: 1px solid var(--border);
        padding: 9px 14px;
    }

    .product-history-data-table td {
        align-items: start;
        border: 0;
        display: grid;
        gap: 12px;
        grid-template-columns: minmax(96px, 0.35fr) minmax(0, 1fr);
        padding: 7px 0;
    }

    .product-history-data-table td::before {
        color: var(--text-3);
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .product-history-timeline-table {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 720px) {
    .product-history-controls-head,
    .product-history-section-head,
    .product-history-decision,
    .product-history-target {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .product-history-periods {
        width: 100%;
    }

    .product-history-filter-grid,
    .product-history-insight-grid,
    .product-history-summary-row {
        grid-template-columns: 1fr;
    }

    .product-history-insight,
    .product-history-insight:nth-child(odd),
    .product-history-insight:nth-child(even),
    .product-history-insight:nth-last-child(-n + 2) {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .product-history-insight:last-child {
        border-bottom: 0;
    }

    .product-history-decision-price {
        align-items: flex-start;
        padding-top: 14px;
        padding-left: 0;
        border-top: 1px solid var(--border);
        border-left: 0;
        text-align: left;
    }

    .product-history-filter-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .product-history-section-actions,
    .product-history-density {
        justify-content: center;
        width: 100%;
    }

    .product-history-density .btn {
        flex: 1 1 0;
    }

    .product-history-target-metrics {
        grid-template-columns: 1fr;
    }

    .product-history-target-metrics > div {
        border-left: 0;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 9px;
    }

    .product-history-timeline-count {
        justify-items: start;
    }

    .product-history-range-legend {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}

@media print {
    .product-history-controls,
    .product-history-filter-actions,
    .product-history-timeline-toolbar {
        display: none !important;
    }

    .product-history-timeline-table {
        max-height: none;
        overflow: visible;
    }
}
