#port-history-dialog { width: min(1080px, calc(100% - 32px)); }
.admin-page #port-history-dialog { width: min(1080px, calc(100% - 32px)); }
#port-history-dialog .admin-close { padding: 0 4px; color: var(--muted); font-size: 24px; line-height: 1; }
#port-history-dialog .admin-feedback { font-size: 12px; line-height: 1.6; color: #ad403d; margin-top: 12px; }
#port-history-dialog .numeric { font-variant-numeric: tabular-nums; }
.history-export { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin: 0 0 10px; }
.history-export select { height: 36px; border: 1px solid var(--line); border-radius: 5px; padding: 0 26px 0 10px; background: #fff; font: inherit; font-size: 12px; }
.history-speed-table .admin-table-scroll { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.history-speed-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.history-speed-table th { background: #fafafb; color: var(--muted); font-size: 11px; font-weight: 450; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.history-speed-table td { padding: 12px 16px; border-bottom: 1px solid #eff0f2; }
.history-speed-table tr:last-child td { border-bottom: 0; }
.admin-table .port-history-link { display: block; padding: 5px 0 0; color: #526686; }
#port-history-dialog .dialog-header { position: sticky; top: 0; z-index: 2; background: #fff; }
.history-period { margin-bottom: 22px; }
.history-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.history-presets button { border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; font-size: 12px; }
.history-presets button:hover { background: #f3f5f8; }
.history-presets [aria-pressed=true] { background: #edf1f6; border-color: #a9b5c8; color: #293b56; }
.history-dates { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px; }
.history-dates .field { margin: 0; width: 175px; }
.history-dates input { min-width: 0; }
.history-dates button { height: 38px; }
.history-note, .history-resolution, .history-speed-note, .history-footnote { color: var(--muted); font-size: 11px; line-height: 1.7; }
.history-note { margin-top: 10px; }
.history-loading, .history-empty { padding: 32px 0; text-align: center; font-size: 13px; color: var(--muted); }
.history-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding: 20px 0; margin-bottom: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-summary dt { font-size: 12px; color: var(--muted); }
.history-summary dd { margin: 8px 0 0; font-size: 28px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.history-summary small { margin-left: 6px; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.history-view-toolbar { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.history-tabs { display: flex; gap: 24px; }
.history-tabs button { padding: 0 0 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; }
.history-tabs [aria-selected=true] { border-color: var(--ink); color: var(--ink); font-weight: 550; }
.history-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 12px 0 16px; }
.history-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.history-legend i { width: 10px; height: 10px; border-radius: 2px; }
.history-grid-scroll { overflow: auto; max-height: 420px; padding-bottom: 8px; }
.history-grid { min-width: 730px; }
.history-row { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 10px; align-items: center; margin-bottom: 4px; }
.history-day, .history-hour { padding: 5px 0; font-size: 11px; text-align: left; white-space: nowrap; }
.history-day { color: #526686; text-decoration: underline; text-underline-offset: 3px; }
.history-hour small { font-size: 9px; color: var(--subtle); margin-left: 5px; }
.history-cells { display: grid; grid-template-columns: repeat(var(--history-columns), minmax(0, 1fr)); gap: 2px; }
.history-cell { height: 25px; min-width: 0; padding: 0; border-radius: 2px; color: #284d3b; font-size: 8px; cursor: pointer; font-variant-numeric: tabular-nums; }
.history-cell:hover, .history-cell:focus-visible { outline: 2px solid #405674; outline-offset: 1px; z-index: 1; }
.history-cell[data-state=online], .history-legend [data-state=online] { background: #91cba5; }
.history-cell[data-state=offline], .history-legend [data-state=offline] { background: #e88480; color: #70231f; }
.history-cell[data-state=pending], .history-legend [data-state=pending] { background: #efd08b; color: #604b1c; }
.history-cell[data-state=unknown], .history-legend [data-state=unknown] { background: #edf0f3; color: #818895; }
.history-cell[data-state=excluded], .history-legend [data-state=excluded] { background: repeating-linear-gradient(135deg, #e2e5e9 0 3px, #f7f8fa 3px 6px); color: #818895; }
.history-footnote { margin-top: 14px; }
.history-tooltip { position: fixed; inset: auto; margin: 0; padding: 10px 13px; border: 0; border-radius: 7px; background: #191b1d; color: #fff; font-size: 11px; line-height: 1.7; white-space: pre-line; max-width: min(320px, calc(100vw - 24px)); pointer-events: none; box-shadow: 0 6px 20px #0002; }
.history-speed-chart { margin: 16px 0 24px; }
.history-speed-chart svg { display: block; width: 100%; min-height: 120px; }
.history-speed-chart svg text { fill: #7c8593; font-size: 11px; }
.history-chart-line { fill: none; stroke: #e8ebf0; stroke-width: 1; }
.history-speed-chart [data-speed-band] { cursor: help; fill: #24845b; }
.history-speed-chart [data-speed-band=low], .history-speed-chart [data-speed-band=failed] { fill: #dc5b57; }
.history-speed-chart [data-speed-band=fair] { fill: #e9bc4d; }
.history-speed-chart [data-speed-band=good] { fill: #97c862; }
.history-chart-range { display: flex; justify-content: space-between; gap: 10px; color: var(--subtle); font-size: 10px; }
.history-speed-table .admin-table { min-width: 540px; }
.history-speed-table .admin-table-scroll { max-height: 350px; overflow: auto; }
.history-speed-table th { position: sticky; top: 0; z-index: 1; }
.history-speed-table .admin-table td { height: auto; padding-block: 12px; }
.history-speed-table .admin-table td:last-child { text-align: left; width: auto; white-space: normal; }
.history-speed-result { color: #35784c; }
.history-speed-result[data-failed] { color: #ad403d; }
.history-pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.history-pagination > div { display: flex; gap: 8px; }
@media (max-width: 600px) {
  .history-summary { gap: 14px; }
  .history-summary dt { font-size: 10px; line-height: 1.5; min-height: 3em; }
  .history-summary dd { font-size: 22px; }
  .history-summary small { display: block; margin: 3px 0 0; font-size: 10px; }
  .history-dates .field { width: calc(50% - 5px); }
  .history-grid-scroll { max-height: 340px; }
  .history-tabs { gap: 20px; }
  .history-tabs button { font-size: 12px; }
}
