.scheduled-panel {
  gap: 18px;
}

.scheduled-head,
.scheduled-tabs,
.scheduled-list-panel,
.scheduled-detail,
.scheduled-feedback {
  width: min(var(--content-width), 100%);
  margin-inline: auto;
}

.scheduled-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 8px;
}

.scheduled-head h1,
.scheduled-detail-card h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.scheduled-head p:last-child,
.scheduled-detail-card header p {
  margin: 5px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.scheduled-head-actions,
.scheduled-detail-actions,
.scheduled-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scheduled-create-split {
  position: relative;
  display: flex;
}

.scheduled-create-split > #scheduledCreate {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.scheduled-create-menu-button {
  min-width: 34px;
  margin-left: 1px;
  padding-inline: 9px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.scheduled-create-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  right: 0;
  display: grid;
  width: 238px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
}

.scheduled-create-menu[hidden] {
  display: none;
}

.scheduled-create-menu button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.scheduled-create-menu button:hover {
  background: var(--hover-tint);
}

.scheduled-create-menu small {
  color: var(--dim);
}

.scheduled-feedback {
  box-sizing: border-box;
  margin-block: -4px 0;
  padding: 9px 12px;
  border: 1px solid oklch(from var(--success) l c h / 0.35);
  border-radius: var(--radius-sm);
  background: oklch(from var(--success) l c h / 0.08);
  color: var(--success);
  font-size: 12.5px;
}

.scheduled-feedback[data-tone="error"] {
  border-color: oklch(from var(--danger) l c h / 0.35);
  background: oklch(from var(--danger) l c h / 0.08);
  color: var(--danger);
}

.scheduled-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}

.scheduled-tabs button {
  position: relative;
  flex: none;
  padding: 9px 12px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.scheduled-tabs button[aria-selected="true"] {
  color: var(--text);
}

.scheduled-tabs button[aria-selected="true"]::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.scheduled-tabs button span {
  display: inline-flex;
  min-width: 18px;
  justify-content: center;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background: var(--panel-2);
  color: var(--dim);
  font-size: 10px;
}

.scheduled-nav-badge {
  min-width: 18px;
  margin-left: auto;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.scheduled-nav-badge[hidden],
.scheduled-tabs button span[hidden] {
  display: none;
}

.scheduled-list-panel {
  min-height: 180px;
}

.scheduled-load-state,
.scheduled-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 34px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 13px;
}

.scheduled-load-state.is-error {
  color: var(--danger);
}

.scheduled-empty strong {
  color: var(--text);
  font-size: 14px;
}

.scheduled-empty p {
  margin: 0;
  line-height: 1.5;
}

.scheduled-list {
  display: grid;
  gap: 10px;
}

.scheduled-run-scope {
  margin: 0 0 2px;
  color: var(--dim);
  font-size: 11.5px;
}

.scheduled-card,
.scheduled-run,
.scheduled-detail-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.scheduled-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 5px;
}

.scheduled-card-open {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.scheduled-card-open:hover {
  background: var(--hover-tint);
}

.scheduled-card-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.scheduled-card-heading strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheduled-attention {
  flex: none;
  padding: 2px 7px;
  border: 1px solid oklch(from var(--danger) l c h / 0.35);
  border-radius: var(--radius-full);
  color: var(--danger);
  font-size: 10.5px;
  font-weight: 700;
}

.scheduled-card-open small {
  color: var(--dim);
}

.scheduled-card-actions {
  padding-right: 10px;
}

.scheduled-status,
.scheduled-run-statuses em {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--muted);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
}

.scheduled-status[data-status="enabled"],
.scheduled-run-statuses em[data-status="delivered"],
.scheduled-run-statuses em[data-status="succeeded"] {
  border-color: oklch(from var(--success) l c h / 0.35);
  color: var(--success);
}

.scheduled-run-statuses em[data-status="failed"],
.scheduled-run-statuses em[data-status="cancelled"],
.scheduled-run-statuses em[data-status="timed_out"] {
  border-color: oklch(from var(--danger) l c h / 0.35);
  color: var(--danger);
}

.scheduled-status[data-status="disabled"],
.scheduled-run-statuses em[data-status="dispatching"],
.scheduled-run-statuses em[data-status="active"] {
  border-color: oklch(from var(--warning) l c h / 0.35);
  color: var(--warning);
}

.scheduled-run-statuses .scheduled-unread {
  border-color: oklch(from var(--accent) l c h / 0.35);
  background: var(--accent-tint);
  color: var(--accent);
}

.scheduled-back {
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.scheduled-back:hover {
  color: var(--text);
}

.scheduled-detail-card {
  padding: 20px;
}

.scheduled-detail-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.scheduled-detail-card > header > div:first-child {
  display: grid;
  gap: 6px;
}

.scheduled-definition {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.scheduled-definition > div {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-canvas);
}

.scheduled-definition > div:last-child {
  grid-column: 1 / -1;
}

.scheduled-definition dt {
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.scheduled-definition dd {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.scheduled-history {
  margin-top: 24px;
}

.scheduled-history h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.scheduled-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
  padding: 13px 14px;
}

.scheduled-run > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.scheduled-run strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheduled-run div > span:not(.scheduled-run-statuses) {
  color: var(--dim);
  font-size: 11.5px;
}

.scheduled-run-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.scheduled-run.is-unread {
  border-color: oklch(from var(--accent) l c h / 0.35);
  background: oklch(from var(--accent) l c h / 0.04);
}

.scheduled-run-error {
  color: var(--danger);
}

.scheduled-run a {
  flex: none;
  text-decoration: none;
}

.scheduled-editor {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  box-sizing: border-box;
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-xl);
}

.scheduled-editor::backdrop {
  background: oklch(0.04 0.01 270 / 0.7);
  backdrop-filter: blur(3px);
}

.scheduled-editor form > header,
.scheduled-editor form > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.scheduled-editor form > header {
  border-bottom: 1px solid var(--line);
}

.scheduled-editor form > header h2 {
  margin: 0;
  font-size: 18px;
}

.scheduled-editor form > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.scheduled-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.scheduled-form-grid > label,
.scheduled-target-fieldset,
.scheduled-recurrence-fields > label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.scheduled-form-wide {
  grid-column: 1 / -1;
}

.scheduled-form-grid input,
.scheduled-form-grid textarea,
.scheduled-form-grid select {
  box-sizing: border-box;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.scheduled-recurrence-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.scheduled-recurrence-fields > [hidden] {
  display: none;
}

.scheduled-interval-inputs {
  display: grid;
  grid-template-columns: minmax(80px, 0.7fr) minmax(120px, 1fr);
  gap: 8px;
}

.scheduled-form-grid textarea {
  resize: vertical;
  line-height: 1.5;
}

.scheduled-form-grid label small {
  color: var(--dim);
  font-weight: 400;
}

.scheduled-target-fieldset {
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.scheduled-target-fieldset legend {
  margin-bottom: 7px;
}

.scheduled-target-fieldset label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.scheduled-target-fieldset input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.scheduled-target-fieldset span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scheduled-target-fieldset strong {
  color: var(--text);
  font-size: 12.5px;
}

.scheduled-target-fieldset small {
  color: var(--dim);
  font-weight: 400;
}

.scheduled-editor-error {
  margin: 0 18px 16px;
  color: var(--danger);
  font-size: 12.5px;
}

.scheduled-panel .danger-action {
  border-color: oklch(from var(--danger) l c h / 0.35);
  color: var(--danger);
}

.scheduled-card button:focus-visible,
.scheduled-tabs button:focus-visible,
.scheduled-back:focus-visible,
.scheduled-create-menu button:focus-visible,
.scheduled-editor :is(input, textarea, select, button):focus-visible,
.scheduled-run a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .scheduled-head,
  .scheduled-detail-card > header {
    align-items: flex-start;
    flex-direction: column;
  }

  .scheduled-head-actions,
  .scheduled-detail-actions {
    flex-wrap: wrap;
  }

  .scheduled-card {
    grid-template-columns: 1fr;
  }

  .scheduled-card-actions {
    padding: 0 12px 10px;
  }

  .scheduled-definition,
  .scheduled-form-grid,
  .scheduled-recurrence-fields {
    grid-template-columns: 1fr;
  }

  .scheduled-definition > div:last-child,
  .scheduled-form-wide {
    grid-column: 1;
  }

  .scheduled-run {
    align-items: flex-start;
    flex-direction: column;
  }
}
