:root {
  --dispatch-canvas: #fafbfd;
  --dispatch-subtle: #edf1f7;
  --dispatch-teal: #0b6b78;
  --dispatch-teal-soft: #e6f6f8;
  --dispatch-purple: #6441a5;
  --dispatch-purple-soft: #f2edfb;
}
:root[data-theme="dark"] {
  --dispatch-canvas: #111723;
  --dispatch-subtle: #1e2738;
  --dispatch-teal: #6dd4e0;
  --dispatch-teal-soft: #15343c;
  --dispatch-purple: #c4a7ff;
  --dispatch-purple-soft: #2a2142;
}
.dispatch-page, #dispatch-overview, #dispatch-bindings { display: grid; gap: 10px; min-width: 0; }
.main:has(#page-dispatch:not([hidden])) { padding-top: 14px; }
.dispatch-heading { gap: 6px; }
.dispatch-heading p { font-size: 12px; }
.dispatch-tabs { justify-self: start; max-width: 100%; flex-wrap: wrap; }
.dispatch-exceptions { justify-self: start; flex-wrap: wrap; }
.dispatch-kpi-strip, .dispatch-channel-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.dispatch-kpi {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.dispatch-kpi span { color: var(--muted); font-size: 11.5px; }
.dispatch-kpi strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.dispatch-kpi:nth-child(4) strong { color: var(--red); }
.dispatch-kpi:nth-child(5) strong { color: var(--green); }
.dispatch-channel {
  min-width: 0; display: flex; flex-direction: column; gap: 6px;
  padding: 9px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer;
}
.dispatch-channel:hover { border-color: var(--border-strong); }
.dispatch-channel.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.dispatch-channel-head, .dispatch-channel-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dispatch-channel-name {
  background: none; border: 0; text-align: left; font-size: 12.5px; font-weight: 700; padding: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dispatch-channel-name:hover { color: var(--primary); text-decoration: underline; }
.dispatch-channel-meta { color: var(--muted); font-size: 12px; }
.dispatch-channel-current {
  display: grid; padding: 5px 7px; gap: 1px; align-content: center; min-height: 42px;
  border: 1px solid var(--dispatch-subtle); border-radius: 6px; background: var(--surface-muted);
}
.dispatch-channel-current strong { font-size: 12px; }
.dispatch-channel-current small { color: var(--muted); font-size: 11px; }
.dispatch-channel-current > *, .dispatch-channel-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dispatch-controls { display: flex; flex-wrap: wrap; gap: 4px; border-top: 1px solid var(--dispatch-subtle); padding-top: 5px; margin-top: auto; }
.dispatch-controls .button { min-height: 24px; padding: 2px 5px; font-size: 11px; flex: 1 0 auto; }
.dispatch-ack {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 4px; padding: 2px 6px;
  border-radius: 4px; color: var(--orange); background: var(--orange-soft); font-size: 10.5px;
}
.dispatch-ack.done { color: var(--green); background: var(--green-soft); }
.dispatch-ack small { width: 100%; font-size: inherit; overflow-wrap: anywhere; }
.dispatch-pill {
  display: inline-flex; gap: 5px; align-items: center; padding: 2px 7px; border-radius: 999px;
  color: var(--muted); background: var(--surface-hover); font-size: 11px; font-weight: 650; white-space: nowrap;
}
.dispatch-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dispatch-pill.dispatch-dedicated::before, .dispatch-channel-meta .dispatch-pill::before { display: none; }
.dispatch-running { color: var(--primary); background: var(--primary-soft); }
.dispatch-verified, .dispatch-waiting { color: var(--dispatch-teal); background: var(--dispatch-teal-soft); }
.dispatch-verified { border: 1px solid color-mix(in srgb, var(--dispatch-teal) 26%, transparent); }
.dispatch-dedicated { color: var(--dispatch-purple); background: var(--dispatch-purple-soft); }
.dispatch-declared { color: var(--green); background: var(--green-soft); }
.dispatch-alert { color: var(--red); background: var(--red-soft); }
.dispatch-pending { color: var(--orange); background: var(--orange-soft); }
.dispatch-public {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  color: var(--muted); background: var(--dispatch-canvas); margin: 10px 14px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px;
}
.dispatch-public strong { color: var(--text); }
.dispatch-panel-head, .dispatch-filter {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px 8px; padding: 9px 13px; border-bottom: 1px solid var(--border);
}
.dispatch-filter { justify-content: flex-start; background: var(--dispatch-canvas); }
.dispatch-filter input, .dispatch-filter select { min-height: 30px; }
.dispatch-filter .search-field { width: min(100%, 216px); }
.dispatch-filter .search-field input { width: 100%; }
.dispatch-filter select { width: auto; max-width: 100%; }
.dispatch-table td, .dispatch-table th { padding: 7px 10px; font-size: 12px; }
.dispatch-table th { font-size: 11.5px; }
.dispatch-table td > small { display: block; margin-top: 2px; color: var(--muted); }
.dispatch-mono { font-family: Consolas, "Cascadia Mono", monospace; font-variant-numeric: tabular-nums; }
.dispatch-row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.dispatch-row-actions .button { padding-inline: 7px; }
.dispatch-notice {
  padding: 8px 12px; border-radius: 8px; color: var(--orange); background: var(--orange-soft);
  border: 1px solid color-mix(in srgb, var(--orange) 25%, var(--border));
}
.dispatch-dialog { width: min(760px, calc(100% - 32px)); max-height: calc(100dvh - 24px); overflow: hidden; padding: 0; }
.dispatch-dialog[open] { display: flex; flex-direction: column; }
.dispatch-dialog .modal-layout { min-height: 0; }
.dispatch-dialog-body { display: grid; gap: 10px; min-height: 0; overflow-y: auto; }
.dispatch-dialog-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.dispatch-dialog textarea {
  min-height: 64px; max-width: 100%; padding: 6px 9px; resize: vertical; font: inherit; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--surface);
}
#dispatch-dialog-error { color: var(--red); }
.dispatch-kv {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 10px 12px; margin: 0;
  background: var(--surface-muted); border: 1px solid var(--dispatch-subtle); border-radius: 8px;
}
.dispatch-kv dt, .dispatch-timeline time { color: var(--muted); font-size: 11.5px; }
.dispatch-kv dd { margin: 2px 0 0; font-size: 12px; overflow-wrap: anywhere; font-weight: 650; }
.dispatch-timeline { display: grid; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.dispatch-timeline li {
  display: grid; grid-template-columns: 110px 112px minmax(0, 1fr); gap: 6px 10px; overflow-wrap: anywhere;
  background: var(--dispatch-canvas); border: 1px solid var(--dispatch-subtle); border-radius: 6px; font-size: 11.5px; padding: 6px 9px;
}
@media (max-width: 1180px) {
  .dispatch-kpi-strip, .dispatch-channel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .dispatch-kpi-strip, .dispatch-channel-grid, .dispatch-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dispatch-task-panel .dispatch-table { display: block; }
  .dispatch-task-panel .dispatch-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .dispatch-task-panel .dispatch-table tbody { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 8px; }
  .dispatch-task-panel .dispatch-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 7px; }
  .dispatch-task-panel .dispatch-table td { display: block; min-width: 0; border: 0; }
  .dispatch-task-panel .dispatch-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; }
  .dispatch-task-panel .dispatch-table td:last-child { grid-column: 1 / -1; }
  .dispatch-task-panel .dispatch-table td:last-child::before { display: none; }
  .dispatch-timeline li { grid-template-columns: repeat(2, minmax(0, auto)); }
  .dispatch-timeline li span { grid-column: 1 / -1; }
}
@media (max-width: 440px) {
  .dispatch-channel-grid { grid-template-columns: minmax(0, 1fr); }
  .dispatch-dialog { width: calc(100% - 16px); }
  .dispatch-dialog .modal-foot { justify-content: flex-start; }
  .dispatch-dialog .modal-foot .toolbar-actions { margin-left: 0; }
}
