.goods-history-summary { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.goods-history-summary h4 { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.goods-history-summary dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; font-size: 12px; }
.goods-history-summary dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.history-open-btn { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; }
.history-open-btn:hover { background: var(--accent-dim); }
.goods-history-modal { position: fixed; inset: 0; z-index: 110; background: rgb(15 23 42 / .48); display: flex; align-items: center; justify-content: center; padding: 20px; }
.goods-history-modal[hidden], #goodsHistoryContent[hidden] { display: none; }
.goods-history-dialog { width: min(1120px, 96vw); max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 8px; padding: 20px; box-shadow: 0 20px 60px rgb(15 23 42 / .3); }
.goods-history-dialog .metric-chart-head h3 { overflow-wrap: anywhere; }
.goods-history-dialog .metric-chart-close { flex: 0 0 30px; }
.goods-history-subtitle { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; margin-bottom: 14px; }
.goods-history-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.goods-history-legend-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-muted); cursor: pointer; font: inherit; font-size: 12px; }
.goods-history-legend-item[aria-pressed="true"] { color: var(--text); background: #f0f5ff; border-color: #cddbf5; }
.goods-history-legend-item[aria-pressed="false"] { opacity: .45; }
.goods-history-legend-swatch { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; }
.goods-history-legend-item:focus-visible, .history-time-handle:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
.goods-history-scale { color: var(--text-muted); font-size: 11px; margin-bottom: 4px; }
.goods-history-hover { height: 40px; overflow: auto; margin: 8px 0; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.goods-history-chart-wrap { width: 100%; height: 360px; border: 1px solid var(--border); border-radius: 8px; background: #fcfdff; padding: 10px 12px 4px; }
#goodsHistoryChart { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.history-time-toolbar { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 14px 0 8px; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.history-time-toolbar button { flex: 0 0 auto; border: 1px solid var(--border); background: white; color: #2563eb; border-radius: 6px; padding: 4px 8px; font: inherit; cursor: pointer; }
.history-time-track { position: relative; height: 32px; margin: 0 10px; background: #eef2f7; border-radius: 6px; touch-action: none; user-select: none; }
.history-time-selection { position: absolute; top: 0; bottom: 0; border: 1px solid #93b4f4; background: #dbeafe; cursor: grab; border-radius: 5px; }
.history-time-selection:active { cursor: grabbing; }
.history-time-handle { position: absolute; top: -3px; bottom: -3px; width: 16px; transform: translateX(-50%); border: 1px solid #82a6ea; border-radius: 5px; background: white; cursor: ew-resize; z-index: 1; box-shadow: 0 1px 3px #0001; }
.history-time-handle::after { content: ''; position: absolute; top: 11px; bottom: 11px; left: 5px; width: 3px; border-left: 1px solid #7b96c4; border-right: 1px solid #7b96c4; }
.history-time-handle[aria-disabled="true"] { cursor: default; }
.history-time-dates { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin: 7px 0 14px; }
.goods-history-table { max-height: 330px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.goods-history-table table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.goods-history-table th, .goods-history-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.goods-history-table th { position: sticky; top: 0; z-index: 1; background: var(--bg); font-weight: 500; }
.goods-history-table th:first-child, .goods-history-table td:first-child { position: sticky; left: 0; text-align: left; background: var(--surface); }
.goods-history-table th:first-child { z-index: 2; background: var(--bg); }
.goods-history-table tbody tr:hover td { background: #f0f7f5; }
.goods-history-table .history-empty { text-align: left; }
#goodsHistoryStatus { font-size: 13px; color: var(--text-muted); }
#goodsHistoryStatus button { margin: 10px 0; padding: 6px 10px; cursor: pointer; }
@media (max-width: 600px) {
  .goods-history-modal { padding: 8px; }
  .goods-history-dialog { width: 100%; max-height: 96dvh; padding: 12px; }
  .goods-history-legend { gap: 6px; }
  .goods-history-legend-item { padding: 4px 7px; }
  .goods-history-chart-wrap { height: 300px; padding: 6px; }
  .goods-history-hover { height: 100px; }
}
