.history-workspace { min-width: 0; }
.history-workspace .note { margin-bottom: 20px; }
.history-tabs { margin-bottom: 24px; }
.history-role, .history-sync { color: var(--subtle); font-size: var(--text-meta); margin: 16px 0; }
.history-summary { padding: 16px 24px; margin: 0; border-bottom: 1px solid var(--line); font-size: var(--text-label); color: var(--subtle); }
.history-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px); align-items: end; gap: 20px; padding: 20px 24px; }
.history-table { width: 100%; border-collapse: collapse; text-align: left; font-size: var(--text-label); }
.history-table th { background: var(--surface); color: var(--subtle); font-size: var(--text-meta); font-weight: 600; padding: 12px 16px; }
.history-table td { border-top: 1px solid var(--line); padding: 20px 16px; vertical-align: top; }
.history-table td:first-child, .history-table th:first-child { padding-left: 24px; }
.history-table td:first-child { max-width: 280px; }
.history-table small { display: block; margin-top: 6px; font-size: var(--text-meta); }
.history-table .history-run-name { display: inline; min-height: 0; padding: 0; text-align: left; overflow-wrap: anywhere; }
.history-table td:last-child .button { padding: 0; min-height: 28px; }
.history-table tbody tr:hover { background: var(--surface); }
.history-warning, .history-status-review, .history-status-paused { color: var(--amber); }
.history-status-failed { color: var(--red); }
.history-status-completed, .history-status-importing, .history-status-collecting { color: var(--green); }
.history-progress { display: grid; gap: 6px; min-width: 150px; font-size: var(--text-meta); font-variant-numeric: tabular-nums; }
.history-progress progress { display: block; width: 100%; height: 7px; border: 0; border-radius: 0; background: var(--line); accent-color: var(--green); }
.history-progress progress::-webkit-progress-bar { background: var(--line); }
.history-progress progress::-webkit-progress-value { background: var(--green); }
.history-progress progress::-moz-progress-bar { background: var(--green); }
.history-progress small { margin: 0; }
.history-settings fieldset, .history-workspace form > fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.history-settings legend, .history-workspace form > fieldset > legend { font-weight: 600; font-size: 1.0625rem; padding: 0; margin: 8px 0 16px; }
.history-settings { gap: 28px; }
.history-workspace .form-grid { align-items: start; }
.history-settings .note { margin-bottom: 0; }
.history-connection-actions { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }
.history-connection-result { margin-top: 16px; color: var(--dark); max-width: 75ch; }
.waha-picker { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; }
.waha-picker .field { flex: 1 1 280px; min-width: 0; }
.waha-current { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 24px; }
.waha-number { font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; margin: 12px 0 4px; font-variant-numeric: tabular-nums; }
.waha-help { max-width: 70ch; margin: 8px 0; }
.waha-checked { color: var(--subtle); font-size: .875rem; margin: 8px 0 20px; }
.waha-connected { background: var(--green-soft); color: var(--dark); }
.waha-warning, .waha-pending { background: var(--amber-soft); color: var(--amber); }
.waha-error { background: var(--red-soft); color: var(--red); }
.waha-qr { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; margin-top: 24px; }
.waha-qr[hidden], .waha-current[hidden] { display: none; }
.waha-qr img { display: block; width: 260px; max-width: 100%; height: auto; background: #fff; padding: 12px; }
.waha-qr > div { flex: 1 1 240px; max-width: 45ch; }
.waha-qr h3 { margin: 0 0 12px; }
.waha-actions { gap: 12px; }
@media (max-width: 600px) {
  .waha-picker { align-items: stretch; }
  .waha-picker .field, .waha-picker > button { flex-basis: 100%; }
  .waha-picker select { font-size: 1rem; }
  .waha-qr { justify-content: center; }
}
.history-chat-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.history-chat-tools > .field { flex: 1; min-width: 200px; }
.history-chat-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); margin-top: 12px; }
.history-chat-list > .check, .history-chat-list > p { padding: 14px 16px; margin: 0; }
.history-chat-list > .check + .check { border-top: 1px solid var(--line); }
.history-chat-list > .check:hover { background: var(--surface); }
.history-chat-list strong { font-weight: 500; overflow-wrap: anywhere; }
.history-selection { margin: 12px 0 0; font-size: var(--text-label); font-weight: 600; }
.history-back { padding-left: 0; margin-bottom: 14px; }
.history-detail-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.history-detail-heading h2 { font-size: 1.375rem; overflow-wrap: anywhere; }
.history-detail-heading p { margin: 6px 0 0; }
.history-detail-heading > .status { padding-top: 6px; white-space: nowrap; }
.history-stages { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0; padding: 0; gap: 20px; }
.history-stages li { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid var(--line); padding-bottom: 14px; color: var(--subtle); font-size: var(--text-label); }
.history-stages .current, .history-stages .done { border-color: var(--green); color: var(--green); }
.history-stages .current { font-weight: 600; }
.history-stage-number { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--control-line); border-radius: 4px; flex-shrink: 0; font-size: var(--text-meta); }
.history-stages .done .history-stage-number, .history-stages .current .history-stage-number { background: var(--green); color: var(--paper); border-color: var(--green); }
.history-destination { font-size: var(--text-label); color: var(--subtle); margin: 0 0 18px; }
.history-facts { display: grid; grid-template-columns: repeat(4, 1fr); margin: 24px 0; gap: 16px; border-top: 1px solid var(--line); padding-top: 20px; }
.history-facts dt { font-size: var(--text-meta); color: var(--subtle); }
.history-facts dd { margin: 6px 0 0; font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.history-preview, .history-events, .history-issues { list-style: none; padding: 0; margin: 0; }
.history-preview li { padding: 20px 24px; }
.history-preview li + li { border-top: 1px solid var(--line); }
.history-preview header { display: flex; justify-content: space-between; gap: 16px; font-size: var(--text-meta); }
.history-preview time { color: var(--subtle); flex-shrink: 0; }
.history-preview p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-label); max-width: 75ch; margin-top: 10px; }
.history-preview small { display: block; margin-top: 8px; }
.history-events li { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 20px; padding: 14px 0; font-size: var(--text-label); border-bottom: 1px solid var(--line); }
.history-events time { color: var(--subtle); font-size: var(--text-meta); }
.history-issues li { display: grid; gap: 4px; padding: 12px 0; font-size: var(--text-label); overflow-wrap: anywhere; }
.history-issues span { color: var(--subtle); }
.history-problems code { white-space: normal; overflow-wrap: anywhere; }
.history-problems form + form { border-top: 1px solid var(--line); padding-top: 20px; }
.history-workspace [hidden] { display: none !important; }
@media (max-width: 1150px) {
  .history-table thead { display: none; }
  .history-table tbody { display: block; }
  .history-table tr { display: grid; grid-template-columns: 1fr 1fr; padding: 16px 24px; gap: 12px 24px; border-top: 1px solid var(--line); }
  .history-table td, .history-table td:first-child { display: block; padding: 0; border: 0; max-width: none; }
  .history-table td:first-child { grid-column: 1/-1; }
  .history-table td:last-child { grid-column: 1/-1; justify-self: end; }
}
@media (max-width: 760px) {
  .history-workspace > .page-heading { margin-bottom: 16px; }
  .history-workspace > .page-heading p, .history-workspace > .page-heading .actions { display: none; }
  .history-workspace > .note { padding: 12px; font-size: var(--text-meta); margin-bottom: 12px; }
  .history-tabs { margin-bottom: 16px; }
  .history-tabs .button { padding-top: 12px; padding-bottom: 12px; }
  .history-summary { padding: 12px 20px; line-height: 1.6; }
  .history-toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 16px 20px; gap: 12px; }
  .history-table tr { grid-template-columns: 1fr; padding: 16px 20px; gap: 10px; }
  .history-table td { grid-column: 1 !important; }
  .history-table td:last-child .button { min-height: 44px; }
  .history-detail-heading { flex-wrap: wrap; gap: 12px; }
  .history-stages { grid-template-columns: 1fr; gap: 12px; margin: 24px 0; }
  .history-stages li { padding-bottom: 10px; }
  .history-facts { grid-template-columns: 1fr 1fr; gap: 20px 12px; }
  .history-preview li { padding: 20px; }
  .history-preview header { flex-wrap: wrap; gap: 4px; }
  .history-events li { grid-template-columns: 1fr; gap: 4px; }
}
