/*
 * Content publishing history workbench.
 * Scoped to .history-command so the rest of the publishing flow keeps its
 * existing layout while this view follows the shared Megia dense-data system.
 */

.history-command {
  --history-success: #10b981;
  --history-failed: #ee1d52;
  --history-cancelled: #94a3b8;
  --history-other: #f59e0b;
  --history-cyan: #69c9d0;
  display: grid;
  gap: var(--ui-section-gap);
}

.history-command .history-command-body {
  position: relative;
  display: grid;
  gap: var(--ui-section-gap);
}

.history-command .history-refresh-progress {
  position: absolute;
  z-index: 80;
  top: -1px;
  right: 18px;
  left: 18px;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(105, 201, 208, 0.12);
  pointer-events: none;
}

.history-command .history-refresh-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--ui-brand-cyan), var(--ui-brand-red), transparent);
  animation: history-refresh-sweep 1.1s ease-in-out infinite;
}

.history-command .history-command-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-surface-radius);
  background:
    radial-gradient(circle at 0 0, rgba(238, 29, 82, 0.075), transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(105, 201, 208, 0.09), transparent 30%),
    var(--ui-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 16px 18px;
}

.history-command .history-command-header::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 18px;
  width: 132px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ui-brand-red), var(--ui-brand-cyan));
}

.history-command .history-command-copy {
  min-width: 240px;
  max-width: 620px;
}

.history-command .history-command-kicker,
.history-command .history-panel-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: var(--ui-text-label);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
}

.history-command .history-command-kicker-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 999px;
  background: var(--history-success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.history-command .history-command-title {
  margin: 5px 0 0;
  color: var(--ui-text);
  font-family: "Chakra Petch", sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-wrap: balance;
}

.history-command .history-command-subtitle {
  margin: 5px 0 0;
  color: var(--ui-text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.history-command .history-filter-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ui-control-gap);
  flex-wrap: wrap;
}

.history-command .history-account-type-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-command .history-filter-caption {
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.history-command .history-account-type-switch {
  display: inline-flex;
  align-items: center;
  height: var(--ui-control-height);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
  padding: 3px;
}

.history-command .history-account-type-button {
  height: 28px;
  min-width: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0 9px;
  color: var(--ui-text-muted);
  cursor: pointer;
  font-family: "Chakra Petch", sans-serif;
  font-size: 11px;
  font-weight: 600;
  transition:
    background-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
  touch-action: manipulation;
}

.history-command .history-account-type-button:hover {
  color: var(--ui-text);
}

.history-command .history-account-type-button.active {
  background: var(--ui-bg);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.history-command .history-account-type-button[data-account-type="all"].active,
.history-command .history-account-type-button[data-account-type="creator"].active {
  color: var(--ui-brand-red);
}

.history-command .history-account-type-button[data-account-type="seller_channel"].active {
  color: #0e7490;
}

.dark .history-command .history-account-type-button.active {
  background: rgba(105, 201, 208, 0.09);
  box-shadow: inset 0 0 0 1px rgba(105, 201, 208, 0.15);
}

.dark .history-command .history-account-type-button[data-account-type="all"].active,
.dark .history-command .history-account-type-button[data-account-type="creator"].active,
.dark .history-command .history-account-type-button[data-account-type="seller_channel"].active {
  color: #a5f3fc;
}

.history-command .history-account-type-count {
  min-width: 18px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.13);
  padding: 0 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.history-command .history-account-type-button.active .history-account-type-count {
  background: rgba(238, 29, 82, 0.11);
  color: var(--ui-brand-red);
}

.history-command .history-account-type-button[data-account-type="seller_channel"].active .history-account-type-count {
  background: rgba(105, 201, 208, 0.15);
  color: #0e7490;
}

.dark .history-command .history-account-type-button.active .history-account-type-count {
  background: rgba(105, 201, 208, 0.14);
  color: #a5f3fc;
}

.history-command .history-filter-divider {
  width: 1px;
  height: 22px;
  flex: 0 0 1px;
  background: var(--ui-border);
}

.history-command .history-preset-group,
.history-command .history-scope-switch {
  display: inline-flex;
  align-items: center;
  height: var(--ui-control-height);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
  padding: 3px;
}

.history-command .history-preset-button,
.history-command .history-scope-button {
  height: 28px;
  min-width: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0 10px;
  color: var(--ui-text-muted);
  cursor: pointer;
  font-family: "Chakra Petch", sans-serif;
  font-size: 11px;
  font-weight: 600;
  transition:
    background-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
  touch-action: manipulation;
}

.history-command .history-preset-button:hover,
.history-command .history-scope-button:hover {
  color: var(--ui-text);
}

.history-command .history-preset-button.active,
.history-command .history-scope-button.active {
  background: var(--ui-bg);
  color: var(--ui-brand-red);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.dark .history-command .history-preset-button.active,
.dark .history-command .history-scope-button.active {
  background: rgba(105, 201, 208, 0.09);
  color: var(--ui-brand-cyan);
  box-shadow: inset 0 0 0 1px rgba(105, 201, 208, 0.15);
}

.history-command .history-account-type-button:focus-visible,
.history-command .history-preset-button:focus-visible,
.history-command .history-scope-button:focus-visible,
.history-command .history-refresh-button:focus-visible,
.history-command .history-panel-link:focus-visible,
.history-command .history-table-toggle:focus-visible,
.history-command .history-day:focus-visible,
.history-command .history-heat-row:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.2);
}

.history-command .history-date-control {
  z-index: 130;
}

.history-command .history-date-control.ui-control-shell {
  height: var(--ui-control-height);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
}

.history-command .history-date-control .studio-filter-date-button {
  min-width: 248px;
}

.history-command .history-date-control [role="dialog"] {
  width: min(320px, calc(100vw - 32px));
}

.history-command .history-refresh-button {
  width: var(--ui-icon-button-size);
  min-width: var(--ui-icon-button-size);
  height: var(--ui-icon-button-size);
  display: inline-flex;
  flex: 0 0 var(--ui-icon-button-size);
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg);
  color: var(--ui-text-muted);
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease;
}

.history-command .history-refresh-button:hover {
  border-color: rgba(105, 201, 208, 0.38);
  background: var(--ui-bg-soft);
  color: var(--history-cyan);
}

.history-command .history-refresh-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.history-command .history-refresh-button svg {
  width: 16px;
  height: 16px;
}

.history-command .history-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.history-command .history-kpi-card {
  --metric-color: var(--history-cyan);
  position: relative;
  min-width: 0;
  min-height: 116px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-surface-radius);
  background: var(--ui-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 15px 16px 14px;
  transition: border-color 0.18s ease;
}

.history-command .history-kpi-card::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--metric-color), transparent 76%);
  opacity: 0.72;
}

.history-command .history-kpi-card:hover {
  transform: none;
  border-color: var(--ui-border);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dark .history-command .history-kpi-card {
  background: var(--ui-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.history-command .history-kpi-glow {
  top: -38px;
  right: -38px;
  width: 104px;
  height: 104px;
  filter: blur(28px);
  opacity: 0.18;
}

.history-command .history-kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--ui-control-radius);
  box-shadow: none;
}

.history-command .history-kpi-icon svg {
  width: 16px;
  height: 16px;
}

.history-command .history-kpi-trend {
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: var(--ui-bg-soft);
  box-shadow: none;
  padding: 4px 7px;
  text-overflow: ellipsis;
  font-size: 10px;
}

.history-command .history-kpi-value {
  margin: 0;
  color: var(--ui-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.history-command .history-kpi-label {
  margin: 7px 0 0;
  color: var(--ui-text-muted);
  font-family: "Chakra Petch", sans-serif;
  font-size: var(--ui-text-label);
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-transform: uppercase;
}

.history-command .history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.75fr);
  gap: var(--ui-section-gap);
  align-items: start;
}

.history-command .history-panel {
  position: relative;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-surface-radius);
  background: var(--ui-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 18px;
}

.history-command #history-trend-panel,
.history-command #history-account-table {
  scroll-margin-top: 80px;
}

.history-command .history-panel::before {
  display: none;
}

.dark .history-command .history-panel {
  background: var(--ui-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.history-command .history-rhythm-panel {
  display: block;
}

.history-command .history-rhythm-panel .history-chart {
  margin: 0;
}

.history-command .history-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
}

.history-command .history-panel-heading {
  min-width: 0;
}

.history-command .history-panel-title {
  margin: 4px 0 0;
  color: var(--ui-text);
  font-family: "Chakra Petch", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  text-wrap: balance;
  scroll-margin-top: 80px;
}

.history-command .history-panel-subtitle {
  margin: 4px 0 0;
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.history-command .history-trend-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-command .history-account-select {
  width: 190px;
  height: var(--ui-control-height);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background-color: var(--ui-bg-soft);
  color: var(--ui-text);
  outline: none;
  padding: 0 32px 0 11px;
  font-size: var(--ui-text-body);
}

.history-command .history-account-select:focus-visible {
  border-color: rgba(105, 201, 208, 0.55);
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.12);
}

.history-command .history-chart-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.history-command .history-insight-chip {
  min-width: 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
  padding: 9px 11px;
}

.history-command .history-insight-label {
  display: block;
  overflow: hidden;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-command .history-insight-value {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--ui-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-command .history-chart-frame {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ui-border);
}

.history-command .history-chart-axis {
  height: 238px;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  align-items: start;
  padding-top: 1px;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-command .history-chart-axis span:last-child {
  align-self: end;
}

.history-command .history-chart-scroll {
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 3px;
  scrollbar-color: rgba(100, 116, 139, 0.36) transparent;
}

.history-command .history-chart {
  --history-chart-height: 238px;
  display: grid;
  grid-template-columns: repeat(var(--history-visible-days), minmax(17px, 1fr));
  gap: clamp(4px, 0.44vw, 8px);
  align-items: end;
  width: 100%;
  min-width: max(600px, calc(var(--history-visible-days) * 20px));
  min-height: calc(var(--history-chart-height) + 30px);
  border: 0;
  padding: 0;
  background-image:
    linear-gradient(
      to bottom,
      rgba(226, 232, 240, 0.72) 1px,
      transparent 1px,
      transparent calc(25% - 1px),
      rgba(226, 232, 240, 0.72) 25%,
      transparent calc(25% + 1px),
      transparent calc(50% - 1px),
      rgba(226, 232, 240, 0.72) 50%,
      transparent calc(50% + 1px),
      transparent calc(75% - 1px),
      rgba(226, 232, 240, 0.72) 75%,
      transparent calc(75% + 1px),
      transparent calc(100% - 1px),
      rgba(226, 232, 240, 0.82) calc(100% - 1px)
    );
  background-position: left top;
  background-repeat: no-repeat;
  background-size: 100% var(--history-chart-height);
}

.dark .history-command .history-chart {
  border: 0;
  background-image:
    linear-gradient(
      to bottom,
      rgba(71, 85, 105, 0.4) 1px,
      transparent 1px,
      transparent calc(25% - 1px),
      rgba(71, 85, 105, 0.4) 25%,
      transparent calc(25% + 1px),
      transparent calc(50% - 1px),
      rgba(71, 85, 105, 0.4) 50%,
      transparent calc(50% + 1px),
      transparent calc(75% - 1px),
      rgba(71, 85, 105, 0.4) 75%,
      transparent calc(75% + 1px),
      transparent calc(100% - 1px),
      rgba(71, 85, 105, 0.5) calc(100% - 1px)
    );
}

.history-command .history-day {
  position: relative;
  display: grid;
  grid-template-rows: var(--history-chart-height) 20px;
  gap: 8px;
  align-items: end;
  min-width: 0;
  border-radius: 6px;
  outline: none;
}

.history-command .history-bar {
  align-self: end;
  display: flex;
  flex-direction: column-reverse;
  justify-self: center;
  width: clamp(10px, 72%, 28px);
  height: var(--history-chart-height);
  overflow: visible;
  border-radius: 5px 5px 2px 2px;
  cursor: default;
  transform-origin: center bottom;
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

.history-command .history-day:hover .history-bar,
.history-command .history-day:focus-visible .history-bar {
  transform: translateY(-2px) scaleX(1.07);
  filter: drop-shadow(0 8px 10px rgba(15, 23, 42, 0.16));
}

.history-command .history-segment {
  width: 100%;
  min-height: 0;
  transition:
    opacity 0.16s ease,
    filter 0.16s ease;
}

.history-command .history-segment:first-of-type {
  border-radius: 0 0 3px 3px;
}

.history-command .history-segment:last-of-type {
  border-radius: 4px 4px 0 0;
}

.history-command .history-chart:hover .history-day:not(:hover) .history-segment {
  opacity: 0.45;
}

.history-command .history-day-label {
  overflow: hidden;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.history-command .history-day-label:empty::after {
  content: "·";
  opacity: 0.38;
}

.history-command .history-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.history-command .history-legend > span {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.history-command .history-legend i,
.history-command .history-tip-row i {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 2px;
  margin-right: 5px;
}

.history-command .history-timeline-slider {
  display: grid;
  grid-template-columns: minmax(130px, auto) minmax(0, 1fr) minmax(80px, auto);
  align-items: center;
  gap: 12px;
  margin: 12px 0 0 42px;
  border-top: 1px solid var(--ui-border);
  padding-top: 12px;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.history-command .history-timeline-slider input[type="range"] {
  width: 100%;
  accent-color: var(--history-cyan);
}

.history-command .history-tooltip {
  position: absolute;
  top: 8px;
  bottom: auto;
  left: 50%;
  z-index: 80;
  min-width: 192px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.15);
  padding: 11px 12px;
  color: var(--ui-text);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.dark .history-command .history-tooltip {
  background: rgba(12, 17, 34, 0.98);
}

.history-command .history-day:nth-child(-n + 3) .history-tooltip {
  right: auto;
  left: 0;
  transform: translateY(4px);
}

.history-command .history-day:nth-last-child(-n + 3) .history-tooltip {
  right: 0;
  left: auto;
  transform: translateY(4px);
}

.history-command .history-day:hover .history-tooltip,
.history-command .history-day:focus-visible .history-tooltip,
.history-command .history-heat-row:hover .history-tooltip,
.history-command .history-heat-row:focus-visible .history-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.history-command .history-day:nth-child(-n + 3):hover .history-tooltip,
.history-command .history-day:nth-child(-n + 3):focus-visible .history-tooltip,
.history-command .history-day:nth-last-child(-n + 3):hover .history-tooltip,
.history-command .history-day:nth-last-child(-n + 3):focus-visible .history-tooltip {
  transform: translateY(0);
}

.history-command .history-tip-title {
  margin-bottom: 7px;
  font-size: 12px;
}

.history-command .history-tip-row {
  font-size: 10px;
  line-height: 1.75;
}

.history-command .history-heat-list {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border-top: 1px solid var(--ui-border);
  padding-top: 10px;
}

.history-command .history-heat-row {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(110px, 1fr) 58px minmax(110px, 1.25fr);
  gap: 9px;
  align-items: center;
  min-height: 45px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 5px 7px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition:
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}

.history-command .history-heat-row:hover,
.history-command .history-heat-row:focus-visible,
.history-command .history-heat-row.active {
  transform: none;
  background: var(--ui-bg-soft);
}

.history-command .history-heat-row.active {
  box-shadow: inset 2px 0 0 var(--history-cyan);
}

.history-command .history-rank {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--ui-bg-soft);
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 600;
}

.history-command .history-heat-row:nth-child(-n + 3) .history-rank {
  background: rgba(105, 201, 208, 0.12);
  color: #0e7490;
}

.dark .history-command .history-heat-row:nth-child(-n + 3) .history-rank {
  color: #a5f3fc;
}

.history-command .history-account-name {
  display: block;
  overflow: hidden;
  color: var(--ui-text);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-command .history-account-button {
  max-width: 100%;
  display: block;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 3px 5px;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.history-command .history-account-button:hover {
  background: rgba(105, 201, 208, 0.08);
}

.history-command .history-account-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.16);
}

.history-command .history-account-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  line-height: 1.2;
}

.history-command .history-heat-row .history-account-meta {
  display: flex;
}

.history-command .history-account-type-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 1px 4px;
  font-family: "Chakra Petch", sans-serif;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.25;
}

.history-command .history-account-type-badge.is-creator {
  background: rgba(241, 245, 249, 0.96);
  color: #475569;
}

.history-command .history-account-type-badge.is-seller {
  background: rgba(105, 201, 208, 0.11);
  color: #0f766e;
}

.history-command .history-account-type-badge.is-unknown {
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
}

.dark .history-command .history-account-type-badge.is-creator {
  background: rgba(30, 41, 59, 0.92);
  color: #cbd5e1;
}

.dark .history-command .history-account-type-badge.is-seller {
  background: rgba(105, 201, 208, 0.13);
  color: #67e8f9;
}

.dark .history-command .history-account-type-badge.is-unknown {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
}

.history-command .history-heat-rate {
  color: var(--ui-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history-command .history-heat-rate.is-strong {
  color: #047857;
}

.history-command .history-heat-rate.is-watch {
  color: #b45309;
}

.history-command .history-heat-rate.is-risk {
  color: #be123c;
}

.dark .history-command .history-heat-rate.is-strong {
  color: #6ee7b7;
}

.dark .history-command .history-heat-rate.is-watch {
  color: #fcd34d;
}

.dark .history-command .history-heat-rate.is-risk {
  color: #fda4af;
}

.history-command .history-track {
  position: relative;
  height: 7px;
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.86);
  cursor: default;
  transform: none;
  transition:
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

.dark .history-command .history-track {
  background: rgba(71, 85, 105, 0.52);
}

.history-command .history-heat-row:hover .history-track,
.history-command .history-heat-row:focus-visible .history-track,
.history-command .history-panel .content-row:hover .history-track {
  transform: none;
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.1);
  filter: saturate(1.08);
}

.history-command .history-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--ui-border);
  padding-top: 12px;
}

.history-command .history-panel-footer-copy {
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.history-command .history-panel-link,
.history-command .history-table-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 0 9px;
  color: #0e7490;
  cursor: pointer;
  font-family: "Chakra Petch", sans-serif;
  font-size: 11px;
  font-weight: 600;
}

.history-command .history-panel-link:hover,
.history-command .history-table-toggle:hover {
  background: rgba(105, 201, 208, 0.1);
}

.dark .history-command .history-panel-link,
.dark .history-command .history-table-toggle {
  color: #a5f3fc;
}

.history-command .history-table-panel {
  padding: 0;
  overflow: hidden;
}

.history-command .history-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 18px 14px;
}

.history-command .history-table-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.history-command .history-table-search {
  position: relative;
  width: 250px;
}

.history-command .history-table-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  color: var(--ui-text-muted);
  pointer-events: none;
}

.history-command .history-table-search input {
  width: 100%;
  height: var(--ui-control-height);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
  color: var(--ui-text);
  outline: none;
  padding: 0 12px 0 34px;
  font-size: var(--ui-text-body);
}

.history-command .history-table-search input:focus-visible {
  border-color: rgba(105, 201, 208, 0.55);
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.12);
}

.history-command .history-table-sort {
  width: 150px;
  height: var(--ui-control-height);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-bg-soft);
  color: var(--ui-text);
  outline: none;
  padding: 0 30px 0 11px;
  font-size: var(--ui-text-body);
}

.history-command .history-table-sort:focus-visible {
  border-color: rgba(105, 201, 208, 0.55);
  box-shadow: 0 0 0 3px rgba(105, 201, 208, 0.12);
}

.history-command .history-table-shell {
  overflow-x: auto;
  border: 0;
  border-top: 1px solid var(--ui-border);
  border-radius: 0;
  background: transparent;
}

.history-command .history-table-shell:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(105, 201, 208, 0.42);
}

.history-command .history-table {
  min-width: 940px;
  table-layout: fixed;
}

.history-command .history-table thead th {
  top: 0;
  z-index: 4;
  background: rgba(248, 250, 252, 0.97);
  padding: 11px 14px;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.dark .history-command .history-table thead th {
  background: rgba(15, 23, 42, 0.98);
}

.history-command .history-table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  color: var(--ui-text);
  font-size: 11px;
}

.history-command .history-table tbody tr {
  height: 52px;
}

.history-command .history-table tbody tr:hover {
  background: rgba(105, 201, 208, 0.04);
  box-shadow: inset 2px 0 0 var(--history-cyan);
}

.history-command .history-table tbody tr.is-focused {
  background: rgba(105, 201, 208, 0.065);
  box-shadow: inset 2px 0 0 var(--history-cyan);
}

.dark .history-command .history-table tbody tr:hover,
.dark .history-command .history-table tbody tr.is-focused {
  background: rgba(105, 201, 208, 0.085);
}

.history-command .history-number {
  color: var(--ui-text);
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.history-command .history-number-success {
  color: #047857;
}

.dark .history-command .history-number-success {
  color: #6ee7b7;
}

.history-command .history-number-failed {
  color: #be123c;
}

.dark .history-command .history-number-failed {
  color: #fda4af;
}

.history-command .history-rate-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--ui-bg-soft);
  padding: 0 8px;
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history-command .history-rate-badge.is-strong {
  border-color: rgba(16, 185, 129, 0.17);
  background: rgba(16, 185, 129, 0.08);
  color: #047857;
}

.history-command .history-rate-badge.is-watch {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.09);
  color: #a16207;
}

.history-command .history-rate-badge.is-risk {
  border-color: rgba(238, 29, 82, 0.18);
  background: rgba(238, 29, 82, 0.08);
  color: #be123c;
}

.dark .history-command .history-rate-badge.is-strong {
  color: #a7f3d0;
}

.dark .history-command .history-rate-badge.is-watch {
  color: #fde68a;
}

.dark .history-command .history-rate-badge.is-risk {
  color: #fda4af;
}

.history-command .history-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-top: 1px solid var(--ui-border);
  padding: 9px 18px;
}

.history-command .history-table-summary {
  color: var(--ui-text-muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.history-command .history-loading-shell,
.history-command .history-empty-state {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-surface-radius);
  background: var(--ui-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.history-command .history-loading-shell {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.history-command .history-loading-header,
.history-command .history-loading-card,
.history-command .history-loading-panel {
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(
      90deg,
      rgba(226, 232, 240, 0.58) 25%,
      rgba(248, 250, 252, 0.95) 50%,
      rgba(226, 232, 240, 0.58) 75%
    );
  background-size: 200% 100%;
  animation: history-shimmer 1.35s ease-in-out infinite;
}

.dark .history-command .history-loading-header,
.dark .history-command .history-loading-card,
.dark .history-command .history-loading-panel {
  background:
    linear-gradient(
      90deg,
      rgba(30, 41, 59, 0.72) 25%,
      rgba(51, 65, 85, 0.78) 50%,
      rgba(30, 41, 59, 0.72) 75%
    );
  background-size: 200% 100%;
}

.history-command .history-loading-header {
  width: min(420px, 70%);
  height: 46px;
}

.history-command .history-loading-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.history-command .history-loading-card {
  height: 106px;
}

.history-command .history-loading-panel {
  height: 330px;
}

.history-command .history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 40px 24px;
  text-align: center;
}

.history-command .history-empty-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(105, 201, 208, 0.2);
  border-radius: 14px;
  background: rgba(105, 201, 208, 0.08);
  color: #0e7490;
}

.history-command .history-empty-icon svg {
  width: 24px;
  height: 24px;
}

.history-command .history-empty-title {
  margin: 16px 0 0;
  color: var(--ui-text);
  font-family: "Chakra Petch", sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.history-command .history-empty-copy {
  max-width: 480px;
  margin: 6px 0 0;
  color: var(--ui-text-muted);
  font-size: 12px;
  line-height: 1.6;
}

@keyframes history-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes history-refresh-sweep {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(360%);
  }
}

@media (max-width: 1540px) {
  .history-command .history-kpi-grid,
  .history-command .history-loading-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .history-command .history-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.75fr);
  }
}

@media (max-width: 1180px) {
  .history-command .history-command-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-command .history-filter-controls {
    width: 100%;
    justify-content: flex-start;
  }

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

  .history-command .history-heat-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-command .history-table-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-command .history-table-tools {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 960px) {
  .history-command .history-heat-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .history-command .history-command-header {
    gap: 16px;
    padding: 15px;
  }

  .history-command .history-command-copy {
    min-width: 0;
  }

  .history-command .history-filter-controls {
    display: grid;
    grid-template-columns: 1fr 36px;
  }

  .history-command .history-account-type-control {
    grid-column: 1 / -1;
    width: 100%;
  }

  .history-command .history-account-type-switch {
    min-width: 0;
    flex: 1 1 auto;
  }

  .history-command .history-account-type-button {
    min-width: 0;
    flex: 1 1 0;
  }

  .history-command .history-filter-divider {
    display: none;
  }

  .history-command .history-preset-group {
    grid-column: 1 / -1;
    width: 100%;
  }

  .history-command .history-preset-button {
    flex: 1 1 0;
  }

  .history-command .history-date-control {
    width: 100%;
  }

  .history-command .history-date-control .studio-filter-date-button {
    width: 100%;
    min-width: 0;
  }

  .history-command .history-kpi-grid,
  .history-command .history-loading-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-command .history-panel {
    padding: 15px;
  }

  .history-command .history-panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-command .history-trend-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .history-command .history-account-select {
    min-width: 0;
    flex: 1 1 180px;
  }

  .history-command .history-chart-insights {
    grid-template-columns: 1fr;
  }

  .history-command .history-chart-frame {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .history-command .history-timeline-slider {
    grid-template-columns: 1fr;
    margin-left: 36px;
  }

  .history-command .history-heat-list {
    grid-template-columns: 1fr;
  }

  .history-command .history-table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .history-command .history-table-search,
  .history-command .history-table-sort {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .history-command .history-account-type-control {
    display: grid;
    gap: 6px;
  }

  .history-command .history-account-type-switch {
    width: 100%;
  }

  .history-command .history-account-type-button {
    gap: 4px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .history-command .history-date-control .studio-filter-label {
    display: none;
  }

  .history-command .history-date-control .studio-filter-date-value {
    gap: 3px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
  }

  .history-command .history-date-control .studio-filter-date-button {
    gap: 6px;
  }

  .history-command .history-date-control .studio-filter-date-value .truncate {
    flex: 0 0 auto;
    overflow: visible;
    text-overflow: clip;
  }

  .history-command .history-kpi-grid,
  .history-command .history-loading-grid {
    grid-template-columns: 1fr;
  }

  .history-command .history-kpi-card {
    min-height: 106px;
  }

  .history-command .history-heat-row {
    grid-template-columns: 26px minmax(96px, 1fr) 52px minmax(92px, 1fr);
    gap: 6px;
    padding-right: 3px;
    padding-left: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-command .history-kpi-card,
  .history-command .history-bar,
  .history-command .history-tooltip,
  .history-command .history-heat-row {
    transition: none;
  }

  .history-command .history-kpi-card:hover,
  .history-command .history-day:hover .history-bar {
    transform: none;
  }

  .history-command .history-loading-header,
  .history-command .history-loading-card,
  .history-command .history-loading-panel,
  .history-command .history-refresh-progress::after {
    animation: none;
  }
}
